﻿window.CodeMirror=function(){function n(a,b){if(!(this instanceof n))return new n(a,b);this.options=b=b||{};for(var c in ob)!b.hasOwnProperty(c)&&ob.hasOwnProperty(c)&&(b[c]=ob[c]);pb(b);c=this.display=Sc(a);c.wrapper.CodeMirror=this;Rb(this);b.autofocus&&!Sb&&E(this);this.view=Tc(new Ha([new Ia([ma("",null,X(c))])]));this.nextOpId=0;Ja(this);Tb(this);b.lineWrapping&&(this.display.wrapper.className+=" CodeMirror-wrap");this.setValue(b.value||"");P&&setTimeout(J(ba,this,!0),20);this.view.history=qb();
Uc(this);var d;try{d=document.activeElement==c.input}catch(e){}d||b.autofocus&&!Sb?setTimeout(J(Y,this),20):rb(this);o(this,function(){for(var a in ca)if(ca.propertyIsEnumerable(a))ca[a](this,b[a],Ub);for(a=0;a<sb.length;++a)sb[a](this)})()}function Sc(a){var b={},c=b.input=r("textarea",null,null,"position: absolute; padding: 0; width: 1px; height: 1em; outline: none;");c.setAttribute("wrap","off");c.setAttribute("autocorrect","off");c.setAttribute("autocapitalize","off");b.inputDiv=r("div",[c],null,
"overflow: hidden; position: relative; width: 3px; height: 0px;");b.scrollbarH=r("div",[r("div",null,null,"height: 1px")],"CodeMirror-hscrollbar");b.scrollbarV=r("div",[r("div",null,null,"width: 1px")],"CodeMirror-vscrollbar");b.scrollbarFiller=r("div",null,"CodeMirror-scrollbar-filler");b.lineDiv=r("div");b.selectionDiv=r("div",null,null,"position: relative; z-index: 1");b.cursor=r("pre"," ","CodeMirror-cursor");b.otherCursor=r("pre"," ","CodeMirror-cursor CodeMirror-secondarycursor");b.measure=
r("div",null,"CodeMirror-measure");b.lineSpace=r("div",[b.measure,b.selectionDiv,b.lineDiv,b.cursor,b.otherCursor],null,"position: relative; outline: none");b.mover=r("div",[r("div",[b.lineSpace],"CodeMirror-lines")],null,"position: relative");b.sizer=r("div",[b.mover],"CodeMirror-sizer");b.heightForcer=r("div"," ",null,"position: absolute; height: "+na+"px");b.gutters=r("div",null,"CodeMirror-gutters");b.lineGutter=null;var d=r("div",[b.sizer,b.heightForcer,b.gutters],null,"position: relative; min-height: 100%");
b.scroller=r("div",[d],"CodeMirror-scroll");b.scroller.setAttribute("tabIndex","-1");b.wrapper=r("div",[b.inputDiv,b.scrollbarH,b.scrollbarV,b.scrollbarFiller,b.scroller],"CodeMirror");da&&(b.gutters.style.zIndex=-1,b.scroller.style.paddingRight=0);a.appendChild?a.appendChild(b.wrapper):a(b.wrapper);Ka&&(c.style.width="0px");Q||(b.scroller.draggable=!0);tb?(b.inputDiv.style.height="1px",b.inputDiv.style.position="absolute"):da&&(b.scrollbarH.style.minWidth=b.scrollbarV.style.minWidth="18px");b.viewOffset=
b.showingFrom=b.showingTo=b.lastSizeC=0;b.lineNumWidth=b.lineNumInnerWidth=b.lineNumChars=null;b.prevInput="";b.alignWidgets=!1;b.pollingFast=!1;b.poll=new ub;b.draggingText=!1;b.cachedCharWidth=b.cachedTextHeight=null;b.measureLineCache=[];b.measureLineCachePos=0;b.inaccurateSelection=!1;b.pasteIncoming=!1;return b}function Tc(a){var b={line:0,ch:0};return{doc:a,frontier:0,highlight:new ub,sel:{from:b,to:b,head:b,anchor:b,shift:!1,extend:!1},scrollTop:0,scrollLeft:0,overwrite:!1,focused:!1,maxLine:q(a,
0),maxLineLength:0,maxLineChanged:!1,suppressEdits:!1,goalColumn:null,cantEdit:!1,keyMaps:[]}}function Ja(a){var b=a.view.doc;a.view.mode=n.getMode(a.options,a.options.mode);b.iter(0,b.size,function(a){a.stateAfter=null});a.view.frontier=0;La(a,100)}function Tb(a){a.display.wrapper.className=a.display.wrapper.className.replace(/\s*cm-s-\S+/g,"")+a.options.theme.replace(/(^|\s)\s*/g," cm-s-");oa(a)}function pa(a){Rb(a);K(a,!0)}function Rb(a){var b=a.display.gutters,c=a.options.gutters;Ma(b);for(var d=
0;d<c.length;++d){var e=c[d],f=b.appendChild(r("div",null,"CodeMirror-gutter "+e));"CodeMirror-linenumbers"==e&&(a.display.lineGutter=f,f.style.width=(a.display.lineNumWidth||1)+"px")}b.style.display=d?"":"none"}function Na(a,b){if(0==b.height)return 0;for(var c=b.text.length,d,e=b;d=qa(e);)d=d.find(),e=q(a,d.from.line),c+=d.from.ch-d.to.ch;for(e=b;d=Oa(e);)d=d.find(),c-=e.text.length-d.from.ch,e=q(a,d.to.line),c+=e.text.length-d.to.ch;return c}function Vb(a){a.maxLine=q(a.doc,0);a.maxLineLength=
Na(a.doc,a.maxLine);a.maxLineChanged=!0;a.doc.iter(1,a.doc.size,function(b){var c=Na(a.doc,b);c>a.maxLineLength&&(a.maxLineLength=c,a.maxLine=b)})}function pb(a){for(var b=!1,c=0;c<a.gutters.length;++c)"CodeMirror-linenumbers"==a.gutters[c]&&(a.lineNumbers?b=!0:a.gutters.splice(c--,1));!b&&a.lineNumbers&&a.gutters.push("CodeMirror-linenumbers")}function Wb(a,b){var c=b+2*a.lineSpace.offsetTop;a.sizer.style.minHeight=a.heightForcer.style.top=c+"px";var c=Math.max(c,a.scroller.scrollHeight),d=a.scroller.scrollWidth>
a.scroller.clientWidth,e=c>a.scroller.clientHeight;e?(a.scrollbarV.style.display="block",a.scrollbarV.style.bottom=d?Pa(a.measure)+"px":"0",a.scrollbarV.firstChild.style.height=c-a.scroller.clientHeight+a.scrollbarV.clientHeight+"px"):a.scrollbarV.style.display="";d?(a.scrollbarH.style.display="block",a.scrollbarH.style.right=e?Pa(a.measure)+"px":"0",a.scrollbarH.firstChild.style.width=a.scroller.scrollWidth-a.scroller.clientWidth+a.scrollbarH.clientWidth+"px"):a.scrollbarH.style.display="";d&&e?
(a.scrollbarFiller.style.display="block",a.scrollbarFiller.style.height=a.scrollbarFiller.style.width=Pa(a.measure)+"px"):a.scrollbarFiller.style.display="";Vc&&0===Pa(a.measure)&&(a.scrollbarV.style.minWidth=a.scrollbarH.style.minHeight=Wc?"18px":"12px")}function Xb(a,b,c){var d=a.scroller.scrollTop,e=a.wrapper.clientHeight;"number"==typeof c?d=c:c&&(d=c.top,e=c.bottom-c.top);d=Math.floor(d-a.lineSpace.offsetTop);a=Math.ceil(d+e);return{from:Qa(b,d),to:Qa(b,a)}}function Xc(a){if(!a.options.lineNumbers)return!1;
var b=""+a.options.lineNumberFormatter(a.view.doc.size-1+a.options.firstLineNumber),a=a.display;if(b.length!=a.lineNumChars){var c=a.measure.appendChild(r("div",[r("div",b)],"CodeMirror-linenumber CodeMirror-gutter-elt")),d=c.firstChild.offsetWidth,c=c.offsetWidth-d;a.lineGutter.style.width="";a.lineNumInnerWidth=Math.max(d,a.lineGutter.offsetWidth-c);a.lineNumWidth=a.lineNumInnerWidth+c;a.lineNumChars=a.lineNumInnerWidth?b.length:-1;a.lineGutter.style.width=a.lineNumWidth+"px";return!0}return!1}
function K(a,b,c){var d=a.display.showingFrom,e=a.display.showingTo;if(b=Yc(a,b,c))ea(a,a,"update",a),(a.display.showingFrom!=d||a.display.showingTo!=e)&&ea(a,a,"viewportChange",a,a.display.showingFrom,a.display.showingTo);vb(a);Wb(a.display,a.view.doc.height);return b}function Yc(a,b,c){var d=a.display,e=a.view.doc;if(d.wrapper.clientWidth){var f=Xb(d,e,c);if(!(!0!==b&&0==b.length&&f.from>d.showingFrom&&f.to<d.showingTo)){b&&Xc(a)&&(b=!0);d.sizer.style.marginLeft=d.scrollbarH.style.left=d.gutters.offsetWidth+
"px";if(!0!==b&&ra)for(var g=0;g<b.length;++g)for(var h=b[g];c=qa(q(e,h.from));)c=c.find().from.line,h.diff&&(h.diff-=h.from-c),h.from=c;h=!0===b?0:Infinity;if(a.options.lineNumbers&&b&&!0!==b)for(g=0;g<b.length;++g)if(b[g].diff){h=b[g].from;break}c=Math.max(f.from-a.options.viewportMargin,0);f=Math.min(e.size,f.to+a.options.viewportMargin);d.showingFrom<c&&20>c-d.showingFrom&&(c=d.showingFrom);d.showingTo>f&&20>d.showingTo-f&&(f=Math.min(e.size,d.showingTo));if(ra)for(c=G(Ra(e,q(e,c)));f<e.size&&
R(q(e,f));)++f;for(var b=!0===b?[]:Zc([{from:d.showingFrom,to:d.showingTo}],b),k=0,g=0;g<b.length;++g){var j=b[g];j.from<c&&(j.from=c);j.to>f&&(j.to=f);j.from>=j.to?b.splice(g--,1):k+=j.to-j.from}if(!(k==f-c&&c==d.showingFrom&&f==d.showingTo)){b.sort(function(a,b){return a.from-b.from});k<0.7*(f-c)&&(d.lineDiv.style.display="none");$c(a,c,f,b,h);d.lineDiv.style.display="";if(c!=d.showingFrom||f!=d.showingTo||d.lastSizeC!=d.wrapper.clientHeight)d.lastSizeC=d.wrapper.clientHeight;d.showingFrom=c;d.showingTo=
f;La(a,100);g=d.lineDiv.offsetTop;for(b=d.lineDiv.firstChild;b;b=b.nextSibling)b.lineObj&&(da?(f=b.offsetTop+b.offsetHeight,h=f-g,g=f):(h=b.getBoundingClientRect(),h=h.bottom-h.top),f=b.lineObj.height-h,2>h&&(h=X(d)),(0.001<f||-0.001>f)&&S(b.lineObj,h));d.viewOffset=sa(a,q(e,c));d.mover.style.top=d.viewOffset+"px";return!0}}}else d.showingFrom=d.showingTo=d.viewOffset=0}function Zc(a,b){for(var c=0,d=b.length||0;c<d;++c){for(var e=b[c],f=[],g=e.diff||0,h=0,k=a.length;h<k;++h){var j=a[h];e.to<=j.from&&
e.diff?f.push({from:j.from+g,to:j.to+g}):e.to<=j.from||e.from>=j.to?f.push(j):(e.from>j.from&&f.push({from:j.from,to:e.from}),e.to<j.to&&f.push({from:e.to+g,to:j.to+g}))}a=f}return a}function ad(a){for(var b=a.display,c={},d={},e=b.gutters.firstChild,f=0;e;e=e.nextSibling,++f)c[a.options.gutters[f]]=e.offsetLeft,d[a.options.gutters[f]]=e.offsetWidth;return{fixedPos:b.scroller.getBoundingClientRect().left-b.sizer.getBoundingClientRect().left,gutterTotalWidth:b.gutters.offsetWidth,gutterLeft:c,gutterWidth:d,
wrapperWidth:b.wrapper.clientWidth}}function $c(a,b,c,d,e){function f(b){var c=b.nextSibling;Q&&fa&&a.display.currentWheelTarget==b?(b.style.display="none",b.lineObj=null):j.removeChild(b);return c}var g=ad(a),h=a.display,k=a.options.lineNumbers;!d.length&&(!P&&(!Q||!a.display.currentWheelTarget))&&Ma(h.lineDiv);var j=h.lineDiv,i=j.firstChild,m=d.shift(),l=b;for(a.view.doc.iter(b,c,function(b){m&&m.to==l&&(m=d.shift());if(R(b))0!=b.height&&S(b,0);else if(m&&m.from<=l&&m.to>l){for(;i.lineObj!=b;)i=
f(i);k&&(e<=l&&i.lineNumber)&&Yb(i.lineNumber,""+a.options.lineNumberFormatter(l+a.options.firstLineNumber));i=i.nextSibling}else{var c;c=a;var h=l,n=Zb(c,b),u=b.gutterMarkers,q=c.display;if(!c.options.lineNumbers&&!u&&!b.bgClass&&!b.wrapClass&&(!b.widgets||!b.widgets.length))c=n;else{var o=r("div",null,b.wrapClass,"position: relative");if(c.options.lineNumbers||u){var Sa=o.appendChild(r("div",null,null,"position: absolute; left: "+g.fixedPos+"px"));o.alignable=[Sa];if(c.options.lineNumbers&&(!u||
!u["CodeMirror-linenumbers"]))o.lineNumber=Sa.appendChild(r("div",""+c.options.lineNumberFormatter(h+c.options.firstLineNumber),"CodeMirror-linenumber CodeMirror-gutter-elt","left: "+g.gutterLeft["CodeMirror-linenumbers"]+"px; width: "+q.lineNumInnerWidth+"px"));if(u)for(h=0;h<c.options.gutters.length;++h){var q=c.options.gutters[h],y=u.hasOwnProperty(q)&&u[q];y&&Sa.appendChild(r("div",[y],"CodeMirror-gutter-elt","left: "+g.gutterLeft[q]+"px; width: "+g.gutterWidth[q]+"px"))}}b.bgClass&&o.appendChild(r("div",
" ",b.bgClass+" CodeMirror-linebackground"));o.appendChild(n);if(b.widgets){u=0;for(h=b.widgets;u<h.length;++u){q=h[u];y=r("div",[q.node],"CodeMirror-linewidget");y.widget=q;if(q.noHScroll){(o.alignable||(o.alignable=[])).push(y);var z=g.wrapperWidth;y.style.left=g.fixedPos+"px";q.coverGutter||(z-=g.gutterTotalWidth,y.style.paddingLeft=g.gutterTotalWidth+"px");y.style.width=z+"px"}q.coverGutter&&(y.style.zIndex=5,y.style.position="relative",q.noHScroll||(y.style.marginLeft=-g.gutterTotalWidth+"px"));
q.above?o.insertBefore(y,c.options.lineNumbers&&0!=b.height?Sa:n):o.appendChild(y)}}da&&(o.style.zIndex=2);c=o}j.insertBefore(c,i);c.lineObj=b}++l});i;)i=f(i)}function vb(a){var b=a.display,c=x(a.view.sel.from,a.view.sel.to);if(c||a.options.showCursorWhenSelecting){var d=a.display,e=T(a,a.view.sel.head,"div");d.cursor.style.left=e.left+"px";d.cursor.style.top=e.top+"px";d.cursor.style.height=Math.max(0,e.bottom-e.top)*a.options.cursorHeight+"px";d.cursor.style.display="";e.other?(d.otherCursor.style.display=
"",d.otherCursor.style.left=e.other.left+"px",d.otherCursor.style.top=e.other.top+"px",d.otherCursor.style.height=0.85*(e.other.bottom-e.other.top)+"px"):d.otherCursor.style.display="none"}else b.cursor.style.display=b.otherCursor.style.display="none";c?b.selectionDiv.style.display="none":bd(a);a=T(a,a.view.sel.head,"div");c=b.wrapper.getBoundingClientRect();d=b.lineDiv.getBoundingClientRect();b.inputDiv.style.top=Math.max(0,Math.min(b.wrapper.clientHeight-10,a.top+d.top-c.top))+"px";b.inputDiv.style.left=
Math.max(0,Math.min(b.wrapper.clientWidth-10,a.left+d.left-c.left))+"px"}function bd(a){function b(a,b,c,d){0>b&&(b=0);g.appendChild(r("div",null,"CodeMirror-selected","position: absolute; left: "+a+"px; top: "+b+"px; width: "+(null==c?h-a:c)+"px; height: "+(d-b)+"px"))}function c(c,d,f,g){var j=q(e,c),i=j.text.length,l=g?Infinity:-Infinity;cd(L(j),d||0,null==f?i:f,function(e,m,q){var o=Ta(a,{line:c,ch:"rtl"==q?m-1:e},"div",j),q=Ta(a,{line:c,ch:"rtl"==q?e:m-1},"div",j),r=o.left,n=q.right;3<q.top-
o.top&&(b(r,o.top,null,o.bottom),r=k,o.bottom<q.top&&b(r,o.bottom,null,q.top));null==f&&m==i&&(n=h);null==d&&0==e&&(r=k);l=g?Math.min(q.top,l):Math.max(q.bottom,l);r<k+1&&(r=k);b(r,q.top,n-r,q.bottom)});return l}var d=a.display,e=a.view.doc,f=a.view.sel,g=document.createDocumentFragment(),h=d.lineSpace.offsetWidth,k=bc(a.display);if(f.from.line==f.to.line)c(f.from.line,f.from.ch,f.to.ch);else{for(var j=q(e,f.from.line),i=j,m=[f.from.line,f.from.ch],l;i=Oa(i);){i=i.find();m.push(i.from.ch,i.to.line,
i.to.ch);if(i.to.line==f.to.line){m.push(f.to.ch);l=!0;break}i=q(e,i.to.line)}if(l)for(f=0;f<m.length;f+=3)c(m[f],m[f+1],m[f+2]);else m=q(e,f.to.line),j=f.from.ch?c(f.from.line,f.from.ch,null,!1):sa(a,j)-d.viewOffset,f=f.to.ch?c(f.to.line,qa(m)?null:0,f.to.ch,!0):sa(a,m)-d.viewOffset,j<f&&b(k,j,null,f)}Z(d.selectionDiv,g);d.selectionDiv.style.display=""}function Ua(a){var b=a.display;clearInterval(b.blinker);var c=!0;b.cursor.style.visibility=b.otherCursor.style.visibility="";b.blinker=setInterval(function(){b.cursor.offsetHeight&&
(b.cursor.style.visibility=b.otherCursor.style.visibility=(c=!c)?"":"hidden")},a.options.cursorBlinkRate)}function La(a,b){a.view.frontier<a.display.showingTo&&a.view.highlight.set(b,J(dd,a))}function dd(a){var b=a.view,c=b.doc;if(!(b.frontier>=a.display.showingTo)){var d=+new Date+a.options.workTime,e=ga(b.mode,ta(a,b.frontier)),f=[],g;c.iter(b.frontier,Math.min(c.size,a.display.showingTo+500),function(c){b.frontier>=a.display.showingFrom?(cc(a,c,e)&&b.frontier>=a.display.showingFrom&&(g&&g.end==
b.frontier?g.end++:f.push(g={start:b.frontier,end:b.frontier+1})),c.stateAfter=ga(b.mode,e)):(dc(a,c,e),c.stateAfter=0==b.frontier%5?ga(b.mode,e):null);++b.frontier;if(+new Date>d)return La(a,a.options.workDelay),!0});f.length&&o(a,function(){for(var a=0;a<f.length;++a)U(this,f[a].start,f[a].end)})()}}function ed(a,b){for(var c,d,e=a.view.doc,f=b,g=b-100;f>g;--f){if(0==f)return 0;var h=q(e,f-1);if(h.stateAfter)return f;h=ha(h.text,null,a.options.tabSize);if(null==d||c>h)d=f-1,c=h}return d}function ta(a,
b){var c=a.view,d=ed(a,b),e=d&&q(c.doc,d-1).stateAfter,e=e?ga(c.mode,e):ec(c.mode);c.doc.iter(d,b,function(f){dc(a,f,e);f.stateAfter=d==b-1||0==d%5||d>=c.showingFrom&&d<c.showingTo?ga(c.mode,e):null;++d});return e}function bc(a){return Z(a.measure,r("pre")).appendChild(r("span","x")).offsetLeft}function wb(a,b,c,d){d=d||xb(a,b);a=-1;for(b=c;;b+=a){var e=d[b];if(e)break;0>a&&0==b&&(a=1)}return{left:b<c?e.right:e.left,right:b>c?e.left:e.right,top:e.top,bottom:e.bottom}}function xb(a,b){for(var c=a.display,
d=a.display.measureLineCache,e=0;e<d.length;++e){var f=d[e];if(f.text==b.text&&f.markedSpans==b.markedSpans&&c.scroller.clientWidth==f.width)return f.measure}var g=a.display,e=fc(b.text.length),h=Zb(a,b,e);if(P&&!da&&!a.options.lineWrapping&&100<h.childNodes.length){for(var k=document.createDocumentFragment(),j=h.childNodes.length,f=0,i=Math.ceil(j/10);f<i;++f){for(var m=r("div",null,null,"display: inline-block"),l=0;10>l&&j;++l)m.appendChild(h.firstChild),--j;k.appendChild(m)}h.appendChild(k)}Z(g.measure,
h);j=g.lineDiv.getBoundingClientRect();k=[];g=fc(b.text.length);h=h.offsetHeight;for(f=0;f<e.length;++f)if(l=e[f]){for(var i=l.getBoundingClientRect(),m=Math.max(0,i.top-j.top),p=Math.min(i.bottom-j.top,h),l=0;l<k.length;l+=2){var q=k[l],o=k[l+1];if(!(q>p||o<m))if(q<=m&&o>=p||m<=q&&p>=o||Math.min(p,o)-Math.max(m,q)>=p-m>>1){k[l]=Math.min(m,q);k[l+1]=Math.max(p,o);break}}l==k.length&&k.push(m,p);g[f]={left:i.left-j.left,right:i.right-j.left,top:l}}for(f=0;f<g.length;++f)if(l=g[f])e=l.top,l.top=k[e],
l.bottom=k[e+1];f={text:b.text,width:c.scroller.clientWidth,markedSpans:b.markedSpans,measure:g};16==d.length?d[++c.measureLineCachePos%16]=f:d.push(f);return g}function oa(a){a.display.measureLineCache.length=a.display.measureLineCachePos=0;a.display.cachedCharWidth=a.display.cachedTextHeight=null;a.view.maxLineChanged=!0}function gc(a,b,c,d){if(b.widgets)for(var e=0;e<b.widgets.length;++e)if(b.widgets[e].above){var f=b.widgets[e].node.offsetHeight;c.top+=f;c.bottom+=f}if("line"==d)return c;d||(d=
"local");b=sa(a,b);"local"!=d&&(b-=a.display.viewOffset);"page"==d&&(a=a.display.lineSpace.getBoundingClientRect(),b+=a.top+(window.pageYOffset||(document.documentElement||document.body).scrollTop),a=a.left+(window.pageXOffset||(document.documentElement||document.body).scrollLeft),c.left+=a,c.right+=a);c.top+=b;c.bottom+=b;return c}function Ta(a,b,c,d){d||(d=q(a.view.doc,b.line));return gc(a,d,wb(a,d,b.ch),c)}function T(a,b,c,d,e){function f(b,f){var g=wb(a,d,b,e);f?g.left=g.right:g.right=g.left;
return gc(a,d,g,c)}d=d||q(a.view.doc,b.line);e||(e=xb(a,d));var g=L(d),b=b.ch;if(!g)return f(b);for(var h,k,j=g[0].level,i=0;i<g.length;++i){var m=g[i],l=m.level%2,p;if(m.from<b&&m.to>b)return f(b,l);var o=l?m.from:m.to;if((l?m.to:m.from)==b)m=i&&m.level<(p=g[i-1]).level?f(p.level%2?p.from:p.to-1,!0):f(l&&m.from!=m.to?b-1:b),l==j?h=m:k=m;else if(o==b&&(p=i<g.length-1&&g[i+1],l||!(p&&p.from==p.to)))m=p&&m.level<p.level?f(p.level%2?p.to-1:p.from):f(l?b:b-1,!0),l==j?h=m:k=m}j&&!b&&(k=f(g[0].to-1));if(!h)return k;
k&&(h.other=k);return h}function yb(a,b,c){var d=a.view.doc,c=c+a.display.viewOffset;if(0>c)return{line:0,ch:0,outside:!0};var e=Qa(d,c);if(e>=d.size)return{line:d.size-1,ch:q(d,d.size-1).text.length};for(0>b&&(b=0);;){var f=q(d,e),e=fd(a,f,e,b,c),g=Oa(f);if(g&&e.ch==ua(f))e=g.find().to.line;else return e}}function fd(a,b,c,d,e){function f(d){d=T(a,{line:c,ch:d},"line",b,j);h=!0;if(g>d.bottom)return Math.max(0,d.left-k);if(g<d.top)return d.left+k;h=!1;return d.left}var g=e-sa(a,b),h=!1,k=a.display.wrapper.clientWidth,
j=xb(a,b),i=L(b),m=b.text.length,e=Va(b),l=ua(b),p=bc(a.display),q=f(l);if(d>q)return{line:c,ch:l,outside:h};for(;;){if(i?l==e||l==zb(b,e,1):1>=l-e){for(e=(d=d-p<q-d)?e:l;Ab.test(b.text.charAt(e));)++e;return{line:c,ch:e,after:d,outside:h}}var o=Math.ceil(m/2),r=e+o;if(i)for(var r=e,n=0;n<o;++n)r=zb(b,r,1);n=f(r);n>d?(l=r,q=n,h&&(q+=1E3),m-=o):(e=r,p=n,m=o)}}function X(a){if(null!=a.cachedTextHeight)return a.cachedTextHeight;if(null==$){$=r("pre");for(var b=0;49>b;++b)$.appendChild(document.createTextNode("x")),
$.appendChild(r("br"));$.appendChild(document.createTextNode("x"))}Z(a.measure,$);b=$.offsetHeight/50;3<b&&(a.cachedTextHeight=b);Ma(a.measure);return b||1}function hc(a){if(null!=a.cachedCharWidth)return a.cachedCharWidth;var b=r("span","x"),c=r("pre",[b]);Z(a.measure,c);b=b.offsetWidth;2<b&&(a.cachedCharWidth=b);return b||10}function Bb(a){a.curOp?++a.curOp.depth:a.curOp={depth:1,changes:[],delayedCallbacks:[],updateInput:null,userSelChange:null,textChanged:null,selectionChanged:!1,updateMaxLine:!1,
id:++a.nextOpId}}function Cb(a){var b=a.curOp;if(!--b.depth){a.curOp=null;var c=a.view,d=a.display;b.updateMaxLine&&Vb(c);if(c.maxLineChanged&&!a.options.lineWrapping){var e=wb(a,c.maxLine,c.maxLine.text.length).right;d.sizer.style.minWidth=e+3+na+"px";c.maxLineChanged=!1}var f,g;b.selectionChanged&&(d=T(a,c.sel.head),f=Db(a,d.left,d.top,d.left,d.bottom));if(b.changes.length||f&&null!=f.scrollTop)g=K(a,b.changes,f&&f.scrollTop);!g&&b.selectionChanged&&vb(a);if(f&&(d=a.view,g=ic(a,d.sel.head),d.focused)){d=
a.display;f=d.sizer.getBoundingClientRect();e=null;if(0>g.top+f.top)e=!0;else if(g.bottom+f.top>(window.innerHeight||document.documentElement.clientHeight))e=!1;if(null!=e&&!gd){if(f="none"==d.cursor.style.display)d.cursor.style.display="",d.cursor.style.left=g.left+"px",d.cursor.style.top=g.top-d.viewOffset+"px";d.cursor.scrollIntoView(e);f&&(d.cursor.style.display="none")}}b.selectionChanged&&Ua(a);c.focused&&b.updateInput&&ba(a,b.userSelChange);b.textChanged&&ia(a,"change",a,b.textChanged);b.selectionChanged&&
ia(a,"cursorActivity",a);for(c=0;c<b.delayedCallbacks.length;++c)b.delayedCallbacks[c](a)}}function o(a,b){return function(){var c=a||this;Bb(c);try{var d=b.apply(c,arguments)}finally{Cb(c)}return d}}function U(a,b,c,d){a.curOp.changes.push({from:b,to:c,diff:d})}function Wa(a){a.view.pollingFast||a.display.poll.set(a.options.pollInterval,function(){Eb(a);a.view.focused&&Wa(a)})}function va(a){function b(){!Eb(a)&&!c?(c=!0,a.display.poll.set(60,b)):(a.display.pollingFast=!1,Wa(a))}var c=!1;a.display.pollingFast=
!0;a.display.poll.set(20,b)}function Eb(a){var b=a.display.input,c=a.display.prevInput,d=a.view,e=d.sel;if(!d.focused||hd(b)||wa(a))return!1;var f=b.value;if(f==c&&x(e.from,e.to))return!1;Bb(a);d.sel.shift=!1;for(var g=0,h=Math.min(c.length,f.length);g<h&&c[g]==f[g];)++g;h=e.from;e=e.to;g<c.length?h={line:h.line,ch:h.ch-(c.length-g)}:d.overwrite&&(x(h,e)&&!a.display.pasteIncoming)&&(e={line:e.line,ch:Math.min(q(a.view.doc,e.line).text.length,e.ch+(f.length-g))});c=a.curOp.updateInput;Fb(a,h,e,xa(f.slice(g)),
"end",a.display.pasteIncoming?"paste":"input",{from:h,to:e});a.curOp.updateInput=c;1E3<f.length?b.value=a.display.prevInput="":a.display.prevInput=f;Cb(a);a.display.pasteIncoming=!1;return!0}function ba(a,b){var c=a.view,d,e;x(c.sel.from,c.sel.to)?b&&(a.display.prevInput=a.display.input.value=""):(a.display.prevInput="",d=jc&&(100<c.sel.to.line-c.sel.from.line||1E3<(e=a.getSelection()).length),a.display.input.value=d?"-":e||a.getSelection(),c.focused&&kc(a.display.input));a.display.inaccurateSelection=
d}function E(a){"nocursor"!=a.options.readOnly&&(P||document.activeElement!=a.display.input)&&a.display.input.focus()}function wa(a){return a.options.readOnly||a.view.cantEdit}function Uc(a){function b(){a.view.focused&&setTimeout(J(E,a),0)}function c(b){(!a.options.onDragEvent||!a.options.onDragEvent(a,ya(b)))&&Xa(b)}function d(){e.inaccurateSelection&&(e.prevInput="",e.inaccurateSelection=!1,e.input.value=a.getSelection(),kc(e.input))}var e=a.display;t(e.scroller,"mousedown",o(a,id));t(e.scroller,
"dblclick",o(a,A));t(e.lineSpace,"selectstart",function(a){lc(e,a)||A(a)});V||t(e.scroller,"contextmenu",function(b){mc(a,b)});t(e.scroller,"scroll",function(){za(a,e.scroller.scrollTop);Aa(a,e.scroller.scrollLeft,!0);ia(a,"scroll",a)});t(e.scrollbarV,"scroll",function(){za(a,e.scrollbarV.scrollTop)});t(e.scrollbarH,"scroll",function(){Aa(a,e.scrollbarH.scrollLeft)});t(e.scroller,"mousewheel",function(b){nc(a,b)});t(e.scroller,"DOMMouseScroll",function(b){nc(a,b)});t(e.scrollbarH,"mousedown",b);t(e.scrollbarV,
"mousedown",b);t(e.wrapper,"scroll",function(){e.wrapper.scrollTop=e.wrapper.scrollLeft=0});t(window,"resize",function g(){e.cachedCharWidth=e.cachedTextHeight=null;oa(a);e.wrapper.parentNode?K(a,!0):M(window,"resize",g)});t(e.input,"keyup",o(a,function(b){if((!a.options.onKeyEvent||!a.options.onKeyEvent(a,ya(b)))&&16==C(b,"keyCode"))a.view.sel.shift=!1}));t(e.input,"input",J(va,a));t(e.input,"keydown",o(a,oc));t(e.input,"keypress",o(a,jd));t(e.input,"focus",J(Y,a));t(e.input,"blur",J(rb,a));a.options.dragDrop&&
(t(e.scroller,"dragstart",function(b){var c=a.getSelection();b.dataTransfer.setData("Text",c);b.dataTransfer.setDragImage&&!Gb&&b.dataTransfer.setDragImage(r("img"),0,0)}),t(e.scroller,"dragenter",c),t(e.scroller,"dragover",c),t(e.scroller,"drop",o(a,kd)));t(e.scroller,"paste",function(){E(a);va(a)});t(e.input,"paste",function(){e.pasteIncoming=true;va(a)});t(e.input,"cut",d);t(e.input,"copy",d);tb&&t(e.sizer,"mouseup",function(){document.activeElement==e.input&&e.input.blur();E(a)})}function lc(a,
b){for(var c=b.target||b.srcElement;c!=a.wrapper;c=c.parentNode)if(/\bCodeMirror-(?:line)?widget\b/.test(c.className)||c.parentNode==a.sizer&&c!=a.mover)return!0}function Ba(a,b,c){var d=a.display;if(!c&&(c=b.target||b.srcElement,c==d.scrollbarH||c==d.scrollbarH.firstChild||c==d.scrollbarV||c==d.scrollbarV.firstChild||c==d.scrollbarFiller))return null;var e,f,d=d.lineSpace.getBoundingClientRect();try{e=b.clientX,f=b.clientY}catch(g){return null}return yb(a,e-d.left,f-d.top)}function id(a){function b(a){if("single"==
m)B(e,s(k,j),a);else if(r=s(k,r),n=s(k,n),"double"==m){var b=pc(q(k,a.line).text,a);w(a,r)?B(e,b.from,n):B(e,r,b.to)}else"triple"==m&&(w(a,r)?B(e,n,s(k,{line:a.line,ch:0})):B(e,r,s(k,{line:a.line+1,ch:0})))}function c(a){var d=++u,h=Ba(e,a,!0);if(h)if(x(h,l)){var j=a.clientY<v.top?-20:a.clientY>v.bottom?20:0;j&&setTimeout(o(e,function(){u==d&&(f.scroller.scrollTop+=j,c(a))}),50)}else{g.focused||Y(e);l=h;b(h);var i=Xb(f,k);(h.line>=i.to||h.line<i.from)&&setTimeout(o(e,function(){u==d&&c(a)}),150)}}
function d(a){u=Infinity;var c=Ba(e,a);c&&b(c);A(a);E(e);M(document,"mousemove",$b);M(document,"mouseup",ac)}var e=this,f=e.display,g=e.view,h=g.sel,k=g.doc;h.shift=C(a,"shiftKey");if(lc(f,a))Q||(f.scroller.draggable=!1,setTimeout(function(){f.scroller.draggable=!0},100));else if(!ld(e,a)){var j=Ba(e,a);switch(qc(a)){case 3:V&&mc.call(e,e,a);return;case 2:j&&B(e,j);setTimeout(J(E,e),20);A(a);return}if(j){g.focused||Y(e);var i=+new Date,m="single";Ya&&Ya.time>i-400&&x(Ya.pos,j)?(m="triple",A(a),setTimeout(J(E,
e),20),md(e,j.line)):Za&&Za.time>i-400&&x(Za.pos,j)?(m="double",Ya={time:i,pos:j},A(a),i=pc(q(k,j.line).text,j),B(e,i.from,i.to)):Za={time:i,pos:j};var l=j;if(e.options.dragDrop&&nd&&!wa(e)&&!x(h.from,h.to)&&!w(j,h.from)&&!w(h.to,j)&&"single"==m){var p=o(e,function(b){if(Q)f.scroller.draggable=false;g.draggingText=false;M(document,"mouseup",p);M(f.scroller,"drop",p);if(Math.abs(a.clientX-b.clientX)+Math.abs(a.clientY-b.clientY)<10){A(b);B(e,j);E(e)}});Q&&(f.scroller.draggable=!0);g.draggingText=p;
f.scroller.dragDrop&&f.scroller.dragDrop();t(document,"mouseup",p);t(f.scroller,"drop",p)}else{A(a);"single"==m&&B(e,s(k,j));var r=h.from,n=h.to,v=f.wrapper.getBoundingClientRect(),u=0,$b=o(e,function(a){!P&&!qc(a)?d(a):c(a)}),ac=o(e,d);t(document,"mousemove",$b);t(document,"mouseup",ac)}}else(a.target||a.srcElement)==f.scroller&&A(a)}}function kd(a){var b=this;if(!b.options.onDragEvent||!b.options.onDragEvent(b,ya(a))){A(a);var c=Ba(b,a,!0),d=a.dataTransfer.files;if(c&&!wa(b))if(d&&d.length&&window.FileReader&&
window.File)for(var e=d.length,f=Array(e),g=0,a=function(a,d){var h=new FileReader;h.onload=function(){f[d]=h.result;++g==e&&(c=s(b.view.doc,c),o(b,function(){var a=W(b,f.join(""),c,c,"paste");N(b,c,a)})())};h.readAsText(a)},h=0;h<e;++h)a(d[h],h);else if(b.view.draggingText&&!w(c,b.view.sel.from)&&!w(b.view.sel.to,c))b.view.draggingText(a),P&&setTimeout(J(E,b),50);else try{if(f=a.dataTransfer.getData("Text")){var h=b.view.sel.from,k=b.view.sel.to;N(b,c,c);b.view.draggingText&&W(b,"",h,k,"paste");
b.replaceSelection(f,null,"paste");E(b);Y(b)}}catch(j){}}}function ld(a,b){var c=a.display;try{var d=b.clientX,e=b.clientY}catch(f){return!1}if(d>=Math.floor(c.gutters.getBoundingClientRect().right))return!1;A(b);if(!rc(a,"gutterClick"))return!0;var g=c.lineDiv.getBoundingClientRect();if(e>g.bottom)return!0;e-=g.top-c.viewOffset;for(g=0;g<a.options.gutters.length;++g){var h=c.gutters.childNodes[g];if(h&&h.getBoundingClientRect().right>=d){c=Qa(a.view.doc,e);ea(a,a,"gutterClick",a,c,a.options.gutters[g],
b);break}}return!0}function za(a,b){2>Math.abs(a.view.scrollTop-b)||(a.view.scrollTop=b,V||K(a,[],b),a.display.scroller.scrollTop!=b&&(a.display.scroller.scrollTop=b),a.display.scrollbarV.scrollTop!=b&&(a.display.scrollbarV.scrollTop=b),V&&K(a,[]))}function Aa(a,b,c){if(!(c?b==a.view.scrollLeft:2>Math.abs(a.view.scrollLeft-b))){a.view.scrollLeft=b;c=a.display;if(c.alignWidgets||c.gutters.firstChild){for(var d=c.scroller.getBoundingClientRect().left-c.sizer.getBoundingClientRect().left-c.scroller.scrollLeft+
a.view.scrollLeft,e=c.gutters.offsetWidth,f=d+"px",g=c.lineDiv.firstChild;g;g=g.nextSibling)if(g.alignable)for(var h=0,k=g.alignable;h<k.length;++h)k[h].style.left=f;c.gutters.style.left=d+e+"px"}a.display.scroller.scrollLeft!=b&&(a.display.scroller.scrollLeft=b);a.display.scrollbarH.scrollLeft!=b&&(a.display.scrollbarH.scrollLeft=b)}}function nc(a,b){var c=b.wheelDeltaX,d=b.wheelDeltaY;null==c&&(b.detail&&b.axis==b.HORIZONTAL_AXIS)&&(c=b.detail);null==d&&b.detail&&b.axis==b.VERTICAL_AXIS?d=b.detail:
null==d&&(d=b.wheelDelta);if(d&&fa&&Q)for(var e=b.target;e!=f;e=e.parentNode)if(e.lineObj){a.display.currentWheelTarget=e;break}var f=a.display.scroller;if(c&&!V&&!ja&&null!=H)d&&za(a,Math.max(0,Math.min(f.scrollTop+d*H,f.scrollHeight-f.clientHeight))),Aa(a,Math.max(0,Math.min(f.scrollLeft+c*H,f.scrollWidth-f.clientWidth))),A(b),ka=null;else{if(d&&null!=H){var e=d*H,g=a.view.scrollTop,h=g+a.display.wrapper.clientHeight;0>e?g=Math.max(0,g+e-50):h=Math.min(a.view.doc.height,h+e+50);K(a,[],{top:g,bottom:h})}20>
$a&&(null==ka?(ka=f.scrollLeft,Hb=f.scrollTop,Ca=c,Da=d,setTimeout(function(){if(ka!=null){var a=f.scrollLeft-ka,b=f.scrollTop-Hb,a=b&&Da&&b/Da||a&&Ca&&a/Ca;ka=Hb=null;if(a){H=(H*$a+a)/($a+1);++$a}}},200)):(Ca+=c,Da+=d))}}function ab(a,b,c){if("string"==typeof b&&(b=Ib[b],!b))return!1;a.display.pollingFast&&Eb(a)&&(a.display.pollingFast=!1);var d=a.view,e=d.sel.shift;try{wa(a)&&(d.suppressEdits=!0),c&&(d.sel.shift=!1),b(a)}catch(f){if(f!=sc)throw f;return!1}finally{d.sel.shift=e,d.suppressEdits=!1}return!0}
function tc(a){var b=a.view.keyMaps.slice(0);b.push(a.options.keyMap);a.options.extraKeys&&b.unshift(a.options.extraKeys);return b}function uc(a,b){function c(){h=!0}var d=Jb(a.options.keyMap),e=d.auto;clearTimeout(vc);e&&!wc(b)&&(vc=setTimeout(function(){Jb(a.options.keyMap)==d&&(a.options.keyMap=e.call?e.call(null,a):e)},50));var f=aa[C(b,"keyCode")],g=!1,g=fa&&(ja||od);if(null==f||b.altGraphKey)return!1;C(b,"altKey")&&(f="Alt-"+f);if(C(b,g?"metaKey":"ctrlKey"))f="Ctrl-"+f;if(C(b,g?"ctrlKey":"metaKey"))f=
"Cmd-"+f;var h=!1,g=tc(a),g=C(b,"shiftKey")?bb("Shift-"+f,g,function(b){return ab(a,b,!0)},c)||bb(f,g,function(b){if("string"==typeof b&&/^go[A-Z]/.test(b))return ab(a,b)},c):bb(f,g,function(b){return ab(a,b)},c);h&&(g=!1);g&&(A(b),Ua(a),cb&&(b.oldKeyCode=b.keyCode,b.keyCode=0));return g}function pd(a,b,c){if(c=bb("'"+c+"'",tc(a),function(b){return ab(a,b,!0)}))A(b),Ua(a);return c}function oc(a){this.view.focused||Y(this);P&&27==a.keyCode&&(a.returnValue=!1);if(!this.options.onKeyEvent||!this.options.onKeyEvent(this,
ya(a))){var b=C(a,"keyCode");this.view.sel.shift=16==b||C(a,"shiftKey");var c=uc(this,a);ja&&(Kb=c?b:null,!c&&(88==b&&!jc&&C(a,fa?"metaKey":"ctrlKey"))&&this.replaceSelection(""))}}function jd(a){var b=this;if(!b.options.onKeyEvent||!b.options.onKeyEvent(b,ya(a))){var c=C(a,"keyCode"),d=C(a,"charCode");if(ja&&c==Kb)Kb=null,A(a);else if(!(ja&&(!a.which||10>a.which)||tb)||!uc(b,a))c=String.fromCharCode(null==d?c:d),this.options.electricChars&&(this.view.mode.electricChars&&this.options.smartIndent&&
!wa(this)&&-1<this.view.mode.electricChars.indexOf(c))&&setTimeout(o(b,function(){db(b,b.view.sel.to.line,"smart")}),75),pd(b,a,c)||va(b)}}function Y(a){"nocursor"!=a.options.readOnly&&(a.view.focused||(ia(a,"focus",a),a.view.focused=!0,-1==a.display.scroller.className.search(/\bCodeMirror-focused\b/)&&(a.display.scroller.className+=" CodeMirror-focused"),ba(a,!0)),Wa(a),Ua(a))}function rb(a){a.view.focused&&(ia(a,"blur",a),a.view.focused=!1,a.display.scroller.className=a.display.scroller.className.replace(" CodeMirror-focused",
""));clearInterval(a.display.blinker);setTimeout(function(){if(!a.view.focused)a.view.sel.shift=false},150)}function mc(a,b){function c(){d.inputDiv.style.position="relative";d.input.style.cssText=h;cb&&(d.scrollbarV.scrollTop=d.scroller.scrollTop=g);Wa(a);if(null!=d.input.selectionStart){clearTimeout(Lb);var b=d.input.value=" "+(x(e.from,e.to)?"":d.input.value),c=0;d.prevInput=" ";d.input.selectionStart=1;d.input.selectionEnd=b.length;Lb=setTimeout(function m(){d.prevInput==" "&&d.input.selectionStart==
0?o(a,Ib.selectAll)(a):c++<10?Lb=setTimeout(m,500):ba(a)},200)}}var d=a.display,e=a.view.sel,f=Ba(a,b),g=d.scroller.scrollTop;if(f&&!ja){(x(e.from,e.to)||w(f,e.from)||!w(f,e.to))&&o(a,N)(a,f,f);var h=d.input.style.cssText;d.inputDiv.style.position="absolute";d.input.style.cssText="position: fixed; width: 30px; height: 30px; top: "+(b.clientY-5)+"px; left: "+(b.clientX-5)+"px; z-index: 1000; background: white; outline: none;border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);";
E(a);ba(a,!0);x(e.from,e.to)&&(d.input.value=d.prevInput=" ");V?(Xa(b),t(window,"mouseup",function j(){M(window,"mouseup",j);setTimeout(c,20)})):setTimeout(c,50)}}function Fb(a,b,c,d,e,f){var g=xc&&qd(a.view.doc,b,c);if(g){for(b=g.length-1;1<=b;--b)eb(a,g[b].from,g[b].to,[""],f);if(g.length)return eb(a,g[0].from,g[0].to,d,e,f)}else return eb(a,b,c,d,e,f)}function eb(a,b,c,d,e,f){if(!a.view.suppressEdits){var g=a.view,h=[];g.doc.iter(b.line,c.line+1,function(a){h.push(Ea(a.text,a.markedSpans))});var k=
g.sel.from,j=g.sel.to,i=rd(F(h[0]),F(I(h)),b.ch,c.ch,d),c=yc(a,b,c,i,e,f);g.history&&sd(a,b.line,d.length,h,f,k,j,g.sel.from,g.sel.to);return c}}function zc(a,b){var c=a.view.doc,d=a.view.history,e=("undo"==b?d.done:d.undone).pop();if(e){for(var f={events:[],fromBefore:e.fromAfter,toBefore:e.toAfter,fromAfter:e.fromBefore,toAfter:e.toBefore},g=e.events.length-1;0<=g;g-=1){d.dirtyCounter+="undo"==b?-1:1;var h=e.events[g],k=[],j=h.start+h.added;c.iter(h.start,j,function(a){k.push(Ea(a.text,a.markedSpans))});
f.events.push({start:h.start,added:h.old.length,old:k});var i=g?null:{from:e.fromBefore,to:e.toBefore};yc(a,{line:h.start,ch:0},{line:j-1,ch:q(c,j-1).text.length},h.old,i,b)}("undo"==b?d.undone:d.done).push(f)}}function yc(a,b,c,d,e,f){var g=a.view,h=g.doc,k=a.display;if(!g.suppressEdits){var j=c.line-b.line,i=q(h,b.line),m=q(h,c.line),l=!1,p=b.line;a.options.lineWrapping||(p=G(Ra(h,i)),h.iter(p,c.line+1,function(a){if(Na(h,a)==g.maxLineLength)return l=!0}));var o=I(d),r=X(k);if(0==b.ch&&0==c.ch&&
""==D(o)){for(var n=[],u=0,t=d.length-1;u<t;++u)n.push(ma(D(d[u]),F(d[u]),r));la(a,m,m.text,F(o));j&&h.remove(b.line,j,a);n.length&&h.insert(b.line,n)}else if(i==m)if(1==d.length)la(a,i,i.text.slice(0,b.ch)+D(d[0])+i.text.slice(c.ch),F(d[0]));else{n=[];u=1;for(t=d.length-1;u<t;++u)n.push(ma(D(d[u]),F(d[u]),r));n.push(ma(D(o)+i.text.slice(c.ch),F(o),r));la(a,i,i.text.slice(0,b.ch)+D(d[0]),F(d[0]));h.insert(b.line+1,n)}else if(1==d.length)la(a,i,i.text.slice(0,b.ch)+D(d[0])+m.text.slice(c.ch),F(d[0])),
h.remove(b.line+1,j,a);else{n=[];la(a,i,i.text.slice(0,b.ch)+D(d[0]),F(d[0]));la(a,m,D(o)+m.text.slice(c.ch),F(o));u=1;for(t=d.length-1;u<t;++u)n.push(ma(D(d[u]),F(d[u]),r));1<j&&h.remove(b.line+1,j-1,a);h.insert(b.line+1,n)}if(a.options.lineWrapping){var v=Math.max(5,k.scroller.clientWidth/hc(k)-3);h.iter(b.line,b.line+d.length,function(a){if(a.height!=0){var b=(Math.ceil(a.text.length/v)||1)*r;b!=a.height&&S(a,b)}})}else h.iter(p,b.line+d.length,function(a){var b=Na(h,a);if(b>g.maxLineLength){g.maxLine=
a;g.maxLineLength=b;g.maxLineChanged=true;l=false}}),l&&(a.curOp.updateMaxLine=!0);g.frontier=Math.min(g.frontier,b.line);La(a,400);var s=d.length-j-1;U(a,b.line,c.line+1,s);if(rc(a,"change")){for(u=0;u<d.length;++u)"string"!=typeof d[u]&&(d[u]=d[u].text);f={from:b,to:c,text:d,origin:f};if(a.curOp.textChanged){for(k=a.curOp.textChanged;k.next;k=k.next);k.next=f}else a.curOp.textChanged=f}var y={line:b.line+d.length-1,ch:D(o).length+(1==d.length?b.ch:0)};e&&"string"!=typeof e?e.from?(d=e.from,e=e.to):
d=e:"end"==e?d=e=y:"start"==e?d=e=b:"around"==e?(d=b,e=y):(e=function(a){if(w(a,b))return a;if(!w(c,a))return y;var d=a.line+s,e=a.ch;a.line==c.line&&(e=e+(D(o).length-(c.ch-(c.line==b.line?b.ch:0))));return{line:d,ch:e}},d=e(g.sel.from),e=e(g.sel.to));N(a,d,e,null,!0);return y}}function W(a,b,c,d,e){d||(d=c);if(w(d,c))var f=d,d=c,c=f;return Fb(a,c,d,xa(b),null,e)}function x(a,b){return a.line==b.line&&a.ch==b.ch}function w(a,b){return a.line<b.line||a.line==b.line&&a.ch<b.ch}function s(a,b){if(0>
b.line)return{line:0,ch:0};if(b.line>=a.size)return{line:a.size-1,ch:q(a,a.size-1).text.length};var c=b.ch,d=q(a,b.line).text.length;return null==c||c>d?{line:b.line,ch:d}:0>c?{line:b.line,ch:0}:b}function B(a,b,c,d){var e=a.view.sel;if(e.shift||e.extend){e=e.anchor;if(c){var f=w(b,e);f!=w(c,e)?(e=b,b=c):f!=w(b,c)&&(b=c)}N(a,e,b,d)}else N(a,b,c||b,d);a.curOp.userSelChange=!0}function N(a,b,c,d,e){a.view.goalColumn=null;var f=a.view.sel;if(e||!x(b,f.anchor))b=fb(a,b,d,"push"!=e);if(e||!x(c,f.head))c=
fb(a,c,d,"push"!=e);if(!x(f.anchor,b)||!x(f.head,c))f.anchor=b,f.head=c,d=w(c,b),f.from=d?c:b,f.to=d?b:c,a.curOp.updateInput=!0,a.curOp.selectionChanged=!0}function Ac(a){N(a,a.view.sel.from,a.view.sel.to,null,"push")}function fb(a,b,c,d){var e=a.view.doc,f=!1,g=b,h=c||1;a.view.cantEdit=!1;a:for(;;){var k=q(e,g.line),j;if(k.markedSpans){for(var i=0;i<k.markedSpans.length;++i){var m=k.markedSpans[i],l=m.marker;if((null==m.from||(l.inclusiveLeft?m.from<=g.ch:m.from<g.ch))&&(null==m.to||(l.inclusiveRight?
m.to>=g.ch:m.to>g.ch)))if(d&&l.clearOnEnter)(j||(j=[])).push(l);else if(l.atomic){i=l.find()[0>h?"from":"to"];if(x(i,g)&&(i.ch+=h,0>i.ch?i=i.line?s(e,{line:i.line-1}):null:i.ch>k.text.length&&(i=i.line<e.size-1?{line:i.line+1,ch:0}:null),!i)){if(f){if(!d)return fb(a,b,c,!0);a.view.cantEdit=!0;return{line:0,ch:0}}f=!0;i=b;h=-h}g=i;continue a}}if(j)for(i=0;i<j.length;++i)j[i].clear()}return g}}function ic(a,b){for(;;){var c=!1,d=T(a,b),e=Db(a,d.left,d.top,d.left,d.bottom),f=a.view.scrollTop,g=a.view.scrollLeft;
null!=e.scrollTop&&(za(a,e.scrollTop),1<Math.abs(a.view.scrollTop-f)&&(c=!0));null!=e.scrollLeft&&(Aa(a,e.scrollLeft),1<Math.abs(a.view.scrollLeft-g)&&(c=!0));if(!c)return d}}function Db(a,b,c,d,e){var f=a.display,g=f.lineSpace.offsetTop,c=c+g,e=e+g,h=f.scroller.clientHeight-na,k=f.scroller.scrollTop,j={},a=a.view.doc.height+2*g,i=c<g+10,g=e+g>a-10;c<k?j.scrollTop=i?0:Math.max(0,c):e>k+h&&(j.scrollTop=(g?a:e)-h);c=f.scroller.clientWidth-na;e=f.scroller.scrollLeft;b+=f.gutters.offsetWidth;d+=f.gutters.offsetWidth;
f=f.gutters.offsetWidth;h=b<f+10;b<e+f||h?(h&&(b=0),j.scrollLeft=Math.max(0,b-10-f)):d>c+e-3&&(j.scrollLeft=d+10-c);return j}function db(a,b,c,d){var e=a.view.doc;c||(c="add");if("smart"==c)if(a.view.mode.indent)var f=ta(a,b);else c="prev";var g=a.options.tabSize,h=q(e,b),k=ha(h.text,null,g),j=h.text.match(/^\s*/)[0],i;if("smart"==c&&(i=a.view.mode.indent(f,h.text.slice(j.length),h.text),i==sc)){if(!d)return;c="prev"}"prev"==c?i=b?ha(q(e,b-1).text,null,g):0:"add"==c?i=k+a.options.indentUnit:"subtract"==
c&&(i=k-a.options.indentUnit);i=Math.max(0,i);c="";d=0;if(a.options.indentWithTabs)for(e=Math.floor(i/g);e;--e)d+=g,c+="\t";d<i&&(c+=Bc(i-d));c!=j&&W(a,c,{line:b,ch:0},{line:b,ch:j.length},"input");h.stateAfter=null}function gb(a,b,c){var d=b,e=b,f=a.view.doc;"number"==typeof b?e=q(f,Math.max(0,Math.min(b,f.size-1))):d=G(b);if(null!=d&&c(e,d))U(a,d,d+1);else return null;return e}function Cc(a,b,c,d){function e(a){var c=(d?zb:Dc)(j,k,b,!0);if(null==c){if(a=!a)a=h+b,0>a||a==f.size?a=!1:(h=a,a=j=q(f,
a));if(a)k=d?(0>b?ua:Va)(j):0>b?j.text.length:0;else return!1}else k=c;return!0}var f=a.view.doc,g=a.view.sel.head,h=g.line,k=g.ch,j=q(f,h);if("char"==c)e();else if("column"==c)e(!0);else if("word"==c)for(c=!1;!(0>b)||e();){if(hb(j.text.charAt(k)))c=!0;else if(c){0>b&&(b=1,e());break}if(0<b&&!e())break}return fb(a,{line:h,ch:k},b,!0)}function pc(a,b){var c=b.ch,d=b.ch;if(a){!1===b.after||d==a.length?--c:++d;for(var e=a.charAt(c),e=hb(e)?hb:/\s/.test(e)?function(a){return/\s/.test(a)}:function(a){return!/\s/.test(a)&&
!hb(a)};0<c&&e(a.charAt(c-1));)--c;for(;d<a.length&&e(a.charAt(d));)++d}return{from:{line:b.line,ch:c},to:{line:b.line,ch:d}}}function md(a,b){B(a,{line:b,ch:0},s(a.view.doc,{line:b+1,ch:0}))}function v(a,b,c,d){n.defaults[a]=b;c&&(ca[a]=d?function(a,b,d){d!=Ub&&c(a,b,d)}:c)}function ga(a,b){if(!0===b)return b;if(a.copyState)return a.copyState(b);var c={},d;for(d in b){var e=b[d];e instanceof Array&&(e=e.concat([]));c[d]=e}return c}function ec(a,b,c){return a.startState?a.startState(b,c):!0}function Jb(a){return"string"==
typeof a?O[a]:a}function bb(a,b,c,d){function e(b){var b=Jb(b),f=b[a];if(!1===f)return d&&d(),!0;if(null!=f&&c(f))return!0;if(b.nofallthrough)return d&&d(),!0;b=b.fallthrough;if(null==b)return!1;if("[object Array]"!=Object.prototype.toString.call(b))return e(b);for(var f=0,k=b.length;f<k;++f)if(e(b[f]))return!0;return!1}for(var f=0;f<b.length;++f)if(e(b[f]))return!0}function wc(a){a=aa[C(a,"keyCode")];return"Ctrl"==a||"Alt"==a||"Shift"==a||"Mod"==a}function Fa(a,b){this.pos=this.start=0;this.string=
a;this.tabSize=b||8}function Mb(a,b){this.lines=[];this.type=b;this.cm=a}function Ec(a,b,c,d,e){var f=a.view.doc,g=new Mb(a,e);if("range"==e&&!w(b,c))return g;if(d)for(var h in d)d.hasOwnProperty(h)&&(g[h]=d[h]);g.replacedWith&&(g.collapsed=!0,g.replacedWith=r("span",[g.replacedWith],"CodeMirror-widget"));g.collapsed&&(ra=!0);var k=b.line,j=0,i,m;f.iter(k,c.line+1,function(a){var d={from:null,to:null,marker:g};j=j+a.text.length;if(k==b.line){d.from=b.ch;j=j-b.ch}if(k==c.line){d.to=c.ch;j=j-(a.text.length-
c.ch)}if(g.collapsed){k==c.line&&(m=ib(a,c.ch));k==b.line?i=ib(a,b.ch):S(a,0)}a.markedSpans=a.markedSpans?a.markedSpans.concat([d]):[d];d.marker.lines.push(a);g.collapsed&&(k==b.line&&R(a))&&S(a,0);++k});g.readOnly&&(xc=!0,(a.view.history.done.length||a.view.history.undone.length)&&a.clearHistory());if(g.collapsed){if(i!=m)throw Error("Inserting collapsed marker overlapping an existing one");g.size=j;g.atomic=!0}(g.className||g.startStyle||g.endStyle||g.collapsed)&&U(a,b.line,c.line+1);g.atomic&&
Ac(a);return g}function jb(a,b){if(a)for(var c=0;c<a.length;++c){var d=a[c];if(d.marker==b)return d}}function rd(a,b,c,d,e){if(!a&&!b)return e;if(a)for(var f=0,g;f<a.length;++f){var h=a[f],k=h.marker;if(null==h.from||(k.inclusiveLeft?h.from<=c:h.from<c)||"bookmark"==k.type&&h.from==c){var j=null==h.to||(k.inclusiveRight?h.to>=c:h.to>c);(g||(g=[])).push({from:h.from,to:j?null:h.to,marker:k})}}a=g;if(b)for(var f=0,i;f<b.length;++f)if(g=b[f],h=g.marker,null==g.to||(h.inclusiveRight?g.to>=d:g.to>d)||
"bookmark"==h.type&&g.from==d&&g.from!=c)k=null==g.from||(h.inclusiveLeft?g.from<=d:g.from<d),(i||(i=[])).push({from:k?null:g.from-d,to:null==g.to?null:g.to-d,marker:h});b=i;i=1==e.length;f=I(e).length+(i?c:0);if(a)for(d=0;d<a.length;++d)g=a[d],null==g.to&&((h=jb(b,g.marker))?i&&(g.to=null==h.to?null:h.to+f):g.to=c);if(b)for(d=0;d<b.length;++d)(g=b[d],null!=g.to&&(g.to+=f),null==g.from)?(h=jb(a,g.marker),h||(g.from=f,i&&(a||(a=[])).push(g))):(g.from+=f,i&&(a||(a=[])).push(g));c=[Ea(e[0],a)];if(!i){i=
e.length-2;var m;if(0<i&&a)for(d=0;d<a.length;++d)null==a[d].to&&(m||(m=[])).push({from:null,to:null,marker:a[d].marker});for(d=0;d<i;++d)c.push(Ea(e[d+1],m));c.push(Ea(I(e),b))}return c}function qd(a,b,c){var d=null;a.iter(b.line,c.line+1,function(a){if(a.markedSpans)for(var b=0;b<a.markedSpans.length;++b){var c=a.markedSpans[b].marker;if(c.readOnly&&(!d||-1==kb(d,c)))(d||(d=[])).push(c)}});if(!d)return null;a=[{from:b,to:c}];for(b=0;b<d.length;++b)for(var c=d[b].find(),e=0;e<a.length;++e){var f=
a[e];if(w(c.from,f.to)&&!w(c.to,f.from)){var g=[e,1];w(f.from,c.from)&&g.push({from:f.from,to:c.from});w(c.to,f.to)&&g.push({from:c.to,to:f.to});a.splice.apply(a,g);e+=g.length-1}}return a}function ib(a,b){var c=ra&&a.markedSpans,d;if(c)for(var e,f=0;f<c.length;++f)if(e=c[f],e.marker.collapsed&&(null==e.from||e.from<b)&&(null==e.to||e.to>b)&&(!d||d.width<e.marker.width))d=e.marker;return d}function qa(a){return ib(a,-1)}function Oa(a){return ib(a,a.text.length+1)}function Ra(a,b){for(var c;c=qa(b);)b=
q(a,c.find().from.line);return b}function R(a){var b=ra&&a.markedSpans;if(b)for(var c,d=0;d<b.length;++d)if(c=b[d],c.marker.collapsed&&(null==c.from||0==c.from&&c.marker.inclusiveLeft&&Fc(a,c)))return!0}function Fc(a,b){if(null==b.to||b.marker.inclusiveRight&&b.to==a.text.length)return!0;for(var c,d=0;d<a.markedSpans.length;++d)if(c=a.markedSpans[d],c.marker.collapsed&&c.from==b.to&&(c.marker.inclusiveLeft||b.marker.inclusiveRight)&&Fc(a,c))return!0}function D(a){return"string"==typeof a?a:a.text}
function F(a){if("string"==typeof a)return null;for(var a=a.markedSpans,b=null,c=0;c<a.length;++c)a[c].marker.explicitlyCleared?b||(b=a.slice(0,c)):b&&b.push(a[c]);return!b?a:b.length?b:null}function Ea(a,b){return b?{text:a,markedSpans:b}:a}function Gc(a){var b=a.markedSpans;if(b){for(var c=0;c<b.length;++c){var d=b[c].marker.lines,e=kb(d,a);d.splice(e,1)}a.markedSpans=null}}function Hc(a,b){if(b){for(var c=0;c<b.length;++c)b[c].marker.lines.push(a);a.markedSpans=b}}function ma(a,b,c){a={text:a,
height:c};Hc(a,b);R(a)&&(a.height=0);return a}function la(a,b,c,d){b.text=c;b.stateAfter=b.styles=null;null!=b.order&&(b.order=null);Gc(b);Hc(b,d);R(b)?b.height=0:b.height||(b.height=X(a.display));ea(a,b,"change")}function cc(a,b,c){var d=a.view.mode,e=a.options.flattenSpans,f=!b.styles,g=0,h="",k=null,a=new Fa(b.text,a.options.tabSize),j=b.styles||(b.styles=[]);for(""==b.text&&d.blankLine&&d.blankLine(c);!a.eol();){var i=d.token(a,c),m=a.current();a.start=a.pos;!e||k!=i?(h&&(f=f||g>=j.length||h!=
j[g]||k!=j[g+1],j[g++]=h,j[g++]=k),h=m,k=i):h+=m;if(5E3<a.pos)break}h&&(f=f||g>=j.length||h!=j[g]||k!=j[g+1],j[g++]=h,j[g++]=k);5E3<a.pos&&(j[g++]=b.text.slice(a.pos),j[g++]=null);g!=j.length&&(j.length=g,f=!0);return f}function dc(a,b,c){var d=a.view.mode,a=new Fa(b.text,a.options.tabSize);for(""==b.text&&d.blankLine&&d.blankLine(c);!a.eol()&&5E3>=a.pos;)d.token(a,c),a.start=a.pos}function Ic(a){return!a?null:Jc[a]||(Jc[a]="cm-"+a.replace(/ +/g," cm-"))}function Zb(a,b,c){for(var d,e=b,f,g,h=!0;d=
qa(e);)h=!1,e=q(a.view.doc,d.find().from.line),f||(f=e);d={pre:r("pre"),col:0,pos:0,display:!c,measure:null,addedOne:!1,cm:a};e.textClass&&(d.pre.className=e.textClass);do{e.styles||cc(a,e,e.stateAfter=ta(a,G(e)));d.measure=e==b&&c;d.pos=0;d.addToken=d.measure?td:Kc;c&&(g&&e!=b&&!d.addedOne)&&(c[0]=d.pre.appendChild(Lc(a.display.measure)),d.addedOne=!0);var k;a:{var j=e;g=d;k=j.styles;var i=j.markedSpans;if(i)for(var j=j.text.length,m=0,l=0,p="",o=void 0,n=0,t=void 0,u=void 0,v=void 0,s=void 0;;){if(n==
m){for(var t=u=v="",s=null,n=Infinity,x=null,y=0;y<i.length;++y){var z=i[y],w=z.marker;if(z.from<=m&&(null==z.to||z.to>m)){if(null!=z.to&&n>z.to&&(n=z.to,u=""),w.className&&(t+=" "+w.className),w.startStyle&&z.from==m&&(v+=" "+w.startStyle),w.endStyle&&z.to==n&&(u+=" "+w.endStyle),w.collapsed&&(!s||s.marker.width<w.width))s=z}else z.from>m&&n>z.from&&(n=z.from);"bookmark"==w.type&&(z.from==m&&w.replacedWith)&&(x=w.replacedWith)}if(s&&(s.from||0)==m)if(Mc(g,(null==s.to?j:s.to)-m,null!=s.from&&s.marker.replacedWith),
null==s.to){k=s.marker.find();break a}x&&!s&&Mc(g,0,x)}if(m>=j)break;for(x=Math.min(j,n);;){if(p){y=m+p.length;s||(z=y>x?p.slice(0,x-m):p,g.addToken(g,z,o+t,v,m+z.length==n?u:""));if(y>=x){p=p.slice(x-m);m=x;break}m=y;v=""}p=k[l++];o=Ic(k[l++])}}else for(var l=0;l<k.length;l+=2)g.addToken(g,k[l],Ic(k[l+1]));k=void 0}g=e==f;k&&(e=q(a.view.doc,k.to.line),h=!1)}while(k);c&&!d.addedOne&&(c[0]=d.pre.appendChild(h?r("span"," "):Lc(a.display.measure)));!d.pre.firstChild&&!R(b)&&d.pre.appendChild(document.createTextNode(" "));
return d.pre}function Kc(a,b,c,d,e){if(b){if(Nb.test(b))for(var f=document.createDocumentFragment(),g=0;;){Nb.lastIndex=g;var h=Nb.exec(b),k=h?h.index-g:b.length-g;k&&(f.appendChild(document.createTextNode(b.slice(g,g+k))),a.col+=k);if(!h)break;g+=k+1;"\t"==h[0]?(h=a.cm.options.tabSize,h-=a.col%h,f.appendChild(r("span",Bc(h),"cm-tab")),a.col+=h):(k=r("span","•","cm-invalidchar"),k.title="\\u"+h[0].charCodeAt(0).toString(16),f.appendChild(k),a.col+=1)}else{a.col+=b.length;var f=document.createTextNode(b)}if(c||
d||e||a.measure)return b=c||"",d&&(b+=d),e&&(b+=e),a.pre.appendChild(r("span",[f],b));a.pre.appendChild(f)}}function td(a,b,c,d,e){for(var f=0;f<b.length;++f)f&&(f<b.length-1&&a.cm.options.lineWrapping&&lb.test(b.slice(f-1,f+1)))&&a.pre.appendChild(r("wbr")),a.measure[a.pos++]=Kc(a,b.charAt(f),c,0==f&&d,f==b.length-1&&e);b.length&&(a.addedOne=!0)}function Mc(a,b,c){c&&(a.display||(c=c.cloneNode(!0)),a.pre.appendChild(c),a.measure&&b&&(a.measure[a.pos]=c,a.addedOne=!0));a.pos+=b}function Ia(a){this.lines=
a;this.parent=null;for(var b=0,c=a.length,d=0;b<c;++b)a[b].parent=this,d+=a[b].height;this.height=d}function Ha(a){this.children=a;for(var b=0,c=0,d=0,e=a.length;d<e;++d){var f=a[d],b=b+f.chunkSize(),c=c+f.height;f.parent=this}this.size=b;this.height=c;this.parent=null}function q(a,b){for(;!a.lines;)for(var c=0;;++c){var d=a.children[c],e=d.chunkSize();if(b<e){a=d;break}b-=e}return a.lines[b]}function S(a,b){for(var c=b-a.height,d=a;d;d=d.parent)d.height+=c}function G(a){if(null==a.parent)return null;
for(var b=a.parent,a=kb(b.lines,a),c=b.parent;c;b=c,c=c.parent)for(var d=0;c.children[d]!=b;++d)a+=c.children[d].chunkSize();return a}function Qa(a,b){var c=0;a:do{for(var d=0,e=a.children.length;d<e;++d){var f=a.children[d],g=f.height;if(b<g){a=f;continue a}b-=g;c+=f.chunkSize()}return c}while(!a.lines);d=0;for(e=a.lines.length;d<e;++d){f=a.lines[d].height;if(b<f)break;b-=f}return c+d}function sa(a,b){for(var b=Ra(a.view.doc,b),c=0,d=b.parent,e=0;e<d.lines.length;++e){var f=d.lines[e];if(f==b)break;
else c+=f.height}for(f=d.parent;f;d=f,f=d.parent)for(e=0;e<f.children.length;++e){var g=f.children[e];if(g==d)break;else c+=g.height}return c}function L(a){var b=a.order;null==b&&(b=a.order=ud(a.text));return b}function qb(){return{done:[],undone:[],lastTime:0,lastOp:null,lastOrigin:null,dirtyCounter:0}}function sd(a,b,c,d,e,f,g,h,k){var j=a.view.history;j.undone.length=0;var i=+new Date,m=I(j.done);if(m&&(j.lastOp==a.curOp.id||j.lastOrigin==e&&("input"==e||"delete"==e)&&j.lastTime>i-600)){f=I(m.events);
if(f.start>b+d.length||f.start+f.added<b)m.events.push({start:b,added:c,old:d});else{for(var g=Math.max(0,f.start-b),l=Math.max(0,b+d.length-(f.start+f.added)),p=g;0<p;--p)f.old.unshift(d[p-1]);for(p=l;0<p;--p)f.old.push(d[d.length-p]);g&&(f.start=b);f.added+=c-(d.length-g-l)}m.fromAfter=h;m.toAfter=k}else{m={events:[{start:b,added:c,old:d}],fromBefore:f,toBefore:g,fromAfter:h,toAfter:k};for(j.done.push(m);j.done.length>a.options.undoDepth;)j.done.shift();0>j.dirtyCounter?j.dirtyCounter=NaN:j.dirtyCounter++}j.lastTime=
i;j.lastOp=a.curOp.id;j.lastOrigin=e}function vd(){Xa(this)}function ya(a){a.stop||(a.stop=vd);return a}function A(a){a.preventDefault?a.preventDefault():a.returnValue=!1}function Nc(a){a.stopPropagation?a.stopPropagation():a.cancelBubble=!0}function Xa(a){A(a);Nc(a)}function qc(a){var b=a.which;null==b&&(a.button&1?b=1:a.button&2?b=3:a.button&4&&(b=2));fa&&(a.ctrlKey&&1==b)&&(b=3);return b}function C(a,b){return a.override&&a.override.hasOwnProperty(b)?a.override[b]:a[b]}function t(a,b,c){a.addEventListener?
a.addEventListener(b,c,!1):a.attachEvent?a.attachEvent("on"+b,c):(a=a._handlers||(a._handlers={}),(a[b]||(a[b]=[])).push(c))}function M(a,b,c){if(a.removeEventListener)a.removeEventListener(b,c,!1);else if(a.detachEvent)a.detachEvent("on"+b,c);else if(a=a._handlers&&a._handlers[b])for(b=0;b<a.length;++b)if(a[b]==c){a.splice(b,1);break}}function ia(a,b){var c=a._handlers&&a._handlers[b];if(c)for(var d=Array.prototype.slice.call(arguments,2),e=0;e<c.length;++e)c[e].apply(null,d)}function ea(a,b,c){function d(a){return function(){a.apply(null,
f)}}var e=b._handlers&&b._handlers[c];if(e)for(var f=Array.prototype.slice.call(arguments,3),g=a.curOp&&a.curOp.delayedCallbacks,h=0;h<e.length;++h)g?g.push(d(e[h])):e[h].apply(null,f)}function rc(a,b){var c=a._handlers&&a._handlers[b];return c&&0<c.length}function ub(){this.id=null}function ha(a,b,c){null==b&&(b=a.search(/[^\s\u00a0]/),-1==b&&(b=a.length));for(var d=0,e=0;d<b;++d)"\t"==a.charAt(d)?e+=c-e%c:++e;return e}function Bc(a){for(;mb.length<=a;)mb.push(I(mb)+" ");return mb[a]}function I(a){return a[a.length-
1]}function kc(a){Ka?(a.selectionStart=0,a.selectionEnd=a.value.length):a.select()}function kb(a,b){if(a.indexOf)return a.indexOf(b);for(var c=0,d=a.length;c<d;++c)if(a[c]==b)return c;return-1}function fc(a){for(var b=[],c=0;c<a;++c)b.push(void 0);return b}function J(a){var b=Array.prototype.slice.call(arguments,1);return function(){return a.apply(null,b)}}function hb(a){return/\w/.test(a)||""<a&&(a.toUpperCase()!=a.toLowerCase()||wd.test(a))}function Oc(a){var b=0,c;for(c in a)a.hasOwnProperty(c)&&
a[c]&&++b;return!b}function r(a,b,c,d){a=document.createElement(a);c&&(a.className=c);d&&(a.style.cssText=d);if("string"==typeof b)Yb(a,b);else if(b)for(c=0;c<b.length;++c)a.appendChild(b[c]);return a}function Ma(a){a.innerHTML="";return a}function Z(a,b){return Ma(a).appendChild(b)}function Yb(a,b){cb?(a.innerHTML="",a.appendChild(document.createTextNode(b))):a.textContent=b}function Pa(a){if(null!=nb)return nb;var b=r("div",null,null,"width: 50px; height: 50px; overflow-x: scroll");Z(a,b);b.offsetWidth&&
(nb=b.offsetHeight-b.clientHeight);return nb||0}function Lc(a){if(null==Ob){var b=r("span","​");Z(a,r("span",[b,document.createTextNode("x")]));0!=a.firstChild.offsetHeight&&(Ob=1>=b.offsetWidth&&2<b.offsetHeight&&!da)}return Ob?r("span","​"):r("span"," ",null,"display: inline-block; width: 1px; margin-right: -1px")}function cd(a,b,c,d){if(!a)return d(b,c,"ltr");for(var e=0;e<a.length;++e){var f=a[e];f.from<c&&f.to>b&&d(Math.max(f.from,b),Math.min(f.to,c),1==f.level?"rtl":"ltr")}}function Pb(a){return a.level%
2?a.from:a.to}function Va(a){return(a=L(a))?a[0].level%2?a[0].to:a[0].from:0}function ua(a){var b=L(a);return!b?a.text.length:Pb(I(b))}function Pc(a,b){var c=q(a.view.doc,b),d=Ra(a.view.doc,c);d!=c&&(b=G(d));c=L(d);d=!c?0:c[0].level%2?ua(d):Va(d);return{line:b,ch:d}}function xd(a,b){for(var c,d;c=Oa(d=q(a.view.doc,b));)b=c.find().to.line;c=L(d);d=!c?d.text.length:c[0].level%2?Va(d):ua(d);return{line:b,ch:d}}function zb(a,b,c,d){var e=L(a);if(!e)return Dc(a,b,c,d);for(var d=d?function(b,c){do b+=c;
while(0<b&&Ab.test(a.text.charAt(b)));return b}:function(a,b){return a+b},f=e[0].level,g=0;g<e.length;++g){var h=e[g],k=h.level%2==f;if(h.from<b&&h.to>b||k&&(h.from==b||h.to==b))break}for(b=d(b,h.level%2?-c:c);null!=b;)if(h.level%2==f)if(b<h.from||b>h.to)b=(h=e[g+=c])&&(0<c==h.level%2?d(h.to,-1):d(h.from,1));else break;else if(b==(h.level%2?h.to:h.from))b=(h=e[--g])&&Pb(h);else if(b==Pb(h))b=(h=e[++g])&&(h.level%2?h.to:h.from);else break;return 0>b||b>a.text.length?null:b}function Dc(a,b,c,d){b+=
c;if(d)for(;0<b&&Ab.test(a.text.charAt(b));)b+=c;return 0>b||b>a.text.length?null:b}var V=/gecko\/\d/i.test(navigator.userAgent),P=/MSIE \d/.test(navigator.userAgent),da=/MSIE [1-7]\b/.test(navigator.userAgent),cb=/MSIE [1-8]\b/.test(navigator.userAgent),Q=/WebKit\//.test(navigator.userAgent),od=Q&&/Qt\/\d+\.\d+/.test(navigator.userAgent),Qc=/Chrome\//.test(navigator.userAgent),ja=/Opera\//.test(navigator.userAgent),Gb=/Apple Computer/.test(navigator.vendor),tb=/KHTML\//.test(navigator.userAgent),
Vc=/Mac OS X 1\d\D([7-9]|\d\d)\D/.test(navigator.userAgent),Wc=/Mac OS X 1\d\D([8-9]|\d\d)\D/.test(navigator.userAgent),gd=/PhantomJS/.test(navigator.userAgent),Ka=/AppleWebKit/.test(navigator.userAgent)&&/Mobile\/\w+/.test(navigator.userAgent),Sb=Ka||/Android|webOS|BlackBerry|Opera Mini|IEMobile/i.test(navigator.userAgent),fa=Ka||/Mac/.test(navigator.platform),xc=!1,ra=!1,$,Za,Ya,$a=0,Ca,Da,ka,Hb,H=null;P?H=-0.53:V?H=15:Qc?H=-0.7:Gb&&(H=-1/3);var vc,Kb=null,Lb;n.prototype={getValue:function(a){var b=
[],c=this.view.doc;c.iter(0,c.size,function(a){b.push(a.text)});return b.join(a||"\n")},setValue:o(null,function(a){var b=this.view.doc,c={line:0,ch:0},d=q(b,b.size-1).text.length;eb(this,c,{line:b.size-1,ch:d},xa(a),c,c,"setValue")}),getSelection:function(a){return this.getRange(this.view.sel.from,this.view.sel.to,a)},replaceSelection:o(null,function(a,b,c){var d=this.view.sel;Fb(this,d.from,d.to,xa(a),b||"around",c)}),focus:function(){window.focus();E(this);Y(this);va(this)},setOption:function(a,
b){var c=this.options,d=c[a];c[a]==b&&"mode"!=a||(c[a]=b,ca.hasOwnProperty(a)&&o(this,ca[a])(this,b,d))},getOption:function(a){return this.options[a]},getMode:function(){return this.view.mode},addKeyMap:function(a){this.view.keyMaps.push(a)},removeKeyMap:function(a){for(var b=this.view.keyMaps,c=0;c<b.length;++c)if(("string"==typeof a?b[c].name:b[c])==a)return b.splice(c,1),!0},undo:o(null,function(){zc(this,"undo")}),redo:o(null,function(){zc(this,"redo")}),indentLine:o(null,function(a,b,c){"string"!=
typeof b&&(b=null==b?this.options.smartIndent?"smart":"prev":b?"add":"subtract");0<=a&&a<this.view.doc.size&&db(this,a,b,c)}),indentSelection:o(null,function(a){var b=this.view.sel;if(x(b.from,b.to))return db(this,b.from.line,a);for(var c=b.to.line-(b.to.ch?0:1),b=b.from.line;b<=c;++b)db(this,b,a)}),historySize:function(){var a=this.view.history;return{undo:a.done.length,redo:a.undone.length}},clearHistory:function(){this.view.history=qb()},markClean:function(){this.view.history.dirtyCounter=0;this.view.history.lastOp=
this.view.history.lastOrigin=null},isClean:function(){return 0==this.view.history.dirtyCounter},getHistory:function(){function a(a){for(var b=0,e=[],f;b<a.length;++b){var g=a[b];e.push({events:f=[],fromBefore:g.fromBefore,toBefore:g.toBefore,fromAfter:g.fromAfter,toAfter:g.toAfter});for(var h=0,g=g.events;h<g.length;++h){var k=[],j=g[h];f.push({start:j.start,added:j.added,old:k});for(var i=0;i<j.old.length;++i)k.push(D(j.old[i]))}}return e}var b=this.view.history;return{done:a(b.done),undone:a(b.undone)}},
setHistory:function(a){var b=this.view.history=qb();b.done=a.done;b.undone=a.undone},getTokenAt:function(a){for(var b=this.view.doc,a=s(b,a),c=ta(this,a.line),d=this.view.mode,b=q(b,a.line),b=new Fa(b.text,this.options.tabSize);b.pos<a.ch&&!b.eol();){b.start=b.pos;var e=d.token(b,c)}return{start:b.start,end:b.pos,string:b.current(),className:e||null,type:e||null,state:c}},getStateAfter:function(a){var b=this.view.doc,a=Math.max(0,Math.min(null==a?b.size-1:a,b.size-1));return ta(this,a+1)},cursorCoords:function(a,
b){var c;c=this.view.sel;c=null==a?c.head:"object"==typeof a?s(this.view.doc,a):a?c.from:c.to;return T(this,c,b||"page")},charCoords:function(a,b){return Ta(this,s(this.view.doc,a),b||"page")},coordsChar:function(a){var b=this.display.lineSpace.getBoundingClientRect();return yb(this,a.left-b.left,a.top-b.top)},defaultTextHeight:function(){return X(this.display)},markText:o(null,function(a,b,c){return Ec(this,s(this.view.doc,a),s(this.view.doc,b),c,"range")}),setBookmark:o(null,function(a,b){a=s(this.view.doc,
a);return Ec(this,a,a,b?{replacedWith:b}:{},"bookmark")}),findMarksAt:function(a){var b=this.view.doc,a=s(b,a),c=[];if(b=q(b,a.line).markedSpans)for(var d=0;d<b.length;++d){var e=b[d];(null==e.from||e.from<=a.ch)&&(null==e.to||e.to>=a.ch)&&c.push(e.marker)}return c},setGutterMarker:o(null,function(a,b,c){return gb(this,a,function(a){var e=a.gutterMarkers||(a.gutterMarkers={});e[b]=c;!c&&Oc(e)&&(a.gutterMarkers=null);return!0})}),clearGutter:o(null,function(a){var b=0,c=this,d=c.view.doc;d.iter(0,
d.size,function(d){d.gutterMarkers&&d.gutterMarkers[a]&&(d.gutterMarkers[a]=null,U(c,b,b+1),Oc(d.gutterMarkers)&&(d.gutterMarkers=null));++b})}),addLineClass:o(null,function(a,b,c){return gb(this,a,function(a){var e="text"==b?"textClass":"background"==b?"bgClass":"wrapClass";if(a[e]){if(RegExp("\\b"+c+"\\b").test(a[e]))return!1;a[e]+=" "+c}else a[e]=c;return!0})}),removeLineClass:o(null,function(a,b,c){return gb(this,a,function(a){var e="text"==b?"textClass":"background"==b?"bgClass":"wrapClass",
f=a[e];if(f)if(null==c)a[e]=null;else{var g=f.replace(RegExp("^"+c+"\\b\\s*|\\s*\\b"+c+"\\b"),"");if(g==f)return!1;a[e]=g||null}else return!1;return!0})}),addLineWidget:o(null,function(a,b,c){var d=c||{};d.node=b;d.noHScroll&&(this.display.alignWidgets=!0);gb(this,a,function(a){(a.widgets||(a.widgets=[])).push(d);d.line=a;return true});return d}),removeLineWidget:o(null,function(a){var b=a.line.widgets,c=G(a.line);if(null!=c){for(var d=0;d<b.length;++d)b[d]==a&&b.splice(d--,1);U(this,c,c+1)}}),lineInfo:function(a){if("number"==
typeof a){if(!(0<=a&&a<this.view.doc.size))return null;var b=a,a=q(this.view.doc,a);if(!a)return null}else if(b=G(a),null==b)return null;return{line:b,handle:a,text:a.text,gutterMarkers:a.gutterMarkers,textClass:a.textClass,bgClass:a.bgClass,wrapClass:a.wrapClass,widgets:a.widgets}},getViewport:function(){return{from:this.display.showingFrom,to:this.display.showingTo}},addWidget:function(a,b,c,d,e){var f=this.display,a=T(this,s(this.view.doc,a)),g=a.top,h=a.left;b.style.position="absolute";f.sizer.appendChild(b);
if("over"==d)g=a.top;else if("near"==d){var d=Math.max(f.wrapper.clientHeight,this.view.doc.height),k=Math.max(f.sizer.clientWidth,f.lineSpace.clientWidth);a.bottom+b.offsetHeight>d&&a.top>b.offsetHeight&&(g=a.top-b.offsetHeight);h+b.offsetWidth>k&&(h=k-b.offsetWidth)}b.style.top=g+f.lineSpace.offsetTop+"px";b.style.left=b.style.right="";"right"==e?(h=f.sizer.clientWidth-b.offsetWidth,b.style.right="0px"):("left"==e?h=0:"middle"==e&&(h=(f.sizer.clientWidth-b.offsetWidth)/2),b.style.left=h+"px");c&&
(a=Db(this,h,g,h+b.offsetWidth,g+b.offsetHeight),null!=a.scrollTop&&za(this,a.scrollTop),null!=a.scrollLeft&&Aa(this,a.scrollLeft))},lineCount:function(){return this.view.doc.size},clipPos:function(a){return s(this.view.doc,a)},getCursor:function(a){var b=this.view.sel,a=null==a||"head"==a?b.head:"anchor"==a?b.anchor:"end"==a||!1===a?b.to:b.from;return{line:a.line,ch:a.ch}},somethingSelected:function(){return!x(this.view.sel.from,this.view.sel.to)},setCursor:o(null,function(a,b,c){a=s(this.view.doc,
"number"==typeof a?{line:a,ch:b||0}:a);c?B(this,a):N(this,a,a)}),setSelection:o(null,function(a,b){var c=this.view.doc;N(this,s(c,a),s(c,b||a))}),extendSelection:o(null,function(a,b){var c=this.view.doc;B(this,s(c,a),b&&s(c,b))}),setExtending:function(a){this.view.sel.extend=a},getLine:function(a){return(a=this.getLineHandle(a))&&a.text},getLineHandle:function(a){var b=this.view.doc;if(0<=a&&a<b.size)return q(b,a)},getLineNumber:function(a){return G(a)},setLine:o(null,function(a,b){0<=a&&a<this.view.doc.size&&
W(this,b,{line:a,ch:0},{line:a,ch:q(this.view.doc,a).text.length})}),removeLine:o(null,function(a){0<=a&&a<this.view.doc.size&&W(this,"",{line:a,ch:0},s(this.view.doc,{line:a+1,ch:0}))}),replaceRange:o(null,function(a,b,c){var d=this.view.doc,b=s(d,b),c=c?s(d,c):b;return W(this,a,b,c)}),getRange:function(a,b,c){var d=this.view.doc,a=s(d,a),b=s(d,b),e=a.line,f=b.line;if(e==f)return q(d,e).text.slice(a.ch,b.ch);var g=[q(d,e).text.slice(a.ch)];d.iter(e+1,f,function(a){g.push(a.text)});g.push(q(d,f).text.slice(0,
b.ch));return g.join(c||"\n")},triggerOnKeyDown:o(null,oc),execCommand:function(a){return Ib[a](this)},moveH:o(null,function(a,b){var c=this.view.sel,d=0>a?c.from:c.to;if(c.shift||c.extend||x(c.from,c.to))d=Cc(this,a,b,!0);B(this,d,d,a)}),deleteH:o(null,function(a,b){var c=this.view.sel;x(c.from,c.to)?W(this,"",c.from,Cc(this,a,b,!1),"delete"):W(this,"",c.from,c.to,"delete");this.curOp.userSelChange=!0}),moveV:o(null,function(a,b){var c=this.view,d=c.doc,e=this.display,f=T(this,c.sel.head,"div"),
g=f.left,h;null!=c.goalColumn&&(g=c.goalColumn);"page"==b?(h=Math.min(e.wrapper.clientHeight,window.innerHeight||document.documentElement.clientHeight),h=f.top+a*h):"line"==b&&(h=0<a?f.bottom+3:f.top-3);do{var k=yb(this,g,h);h+=5*a}while(k.outside&&(0>a?0<h:h<d.height));"page"==b&&(e.scrollbarV.scrollTop+=Ta(this,k,"div").top-f.top);B(this,k,k,a);c.goalColumn=g}),toggleOverwrite:function(){this.display.cursor.className=(this.view.overwrite=!this.view.overwrite)?this.display.cursor.className+" CodeMirror-overwrite":
this.display.cursor.className.replace(" CodeMirror-overwrite","")},posFromIndex:function(a){var b=0,c,d=this.view.doc;d.iter(0,d.size,function(d){d=d.text.length+1;if(d>a)return c=a,!0;a-=d;++b});return s(d,{line:b,ch:c})},indexFromPos:function(a){if(0>a.line||0>a.ch)return 0;var b=a.ch;this.view.doc.iter(0,a.line,function(a){b+=a.text.length+1});return b},scrollTo:function(a,b){null!=a&&(this.display.scrollbarH.scrollLeft=this.display.scroller.scrollLeft=a);null!=b&&(this.display.scrollbarV.scrollTop=
this.display.scroller.scrollTop=b);K(this,[])},getScrollInfo:function(){var a=this.display.scroller,b=na;return{left:a.scrollLeft,top:a.scrollTop,height:a.scrollHeight-b,width:a.scrollWidth-b,clientHeight:a.clientHeight-b,clientWidth:a.clientWidth-b}},scrollIntoView:function(a){"number"==typeof a&&(a={line:a,ch:0});a=a?s(this.view.doc,a):this.view.sel.head;ic(this,a)},setSize:function(a,b){function c(a){return"number"==typeof a||/^\d+$/.test(""+a)?a+"px":a}null!=a&&(this.display.wrapper.style.width=
c(a));null!=b&&(this.display.wrapper.style.height=c(b));this.refresh()},on:function(a,b){t(this,a,b)},off:function(a,b){M(this,a,b)},operation:function(a){return o(this,a)()},refresh:function(){oa(this);this.display.scroller.scrollHeight>this.view.scrollTop&&(this.display.scrollbarV.scrollTop=this.display.scroller.scrollTop=this.view.scrollTop);K(this,!0)},getInputField:function(){return this.display.input},getWrapperElement:function(){return this.display.wrapper},getScrollerElement:function(){return this.display.scroller},
getGutterElement:function(){return this.display.gutters}};var ca=n.optionHandlers={},ob=n.defaults={},Ub=n.Init={toString:function(){return"CodeMirror.Init"}};v("value","",function(a,b){a.setValue(b)},!0);v("mode",null,Ja,!0);v("indentUnit",2,Ja,!0);v("indentWithTabs",!1);v("smartIndent",!0);v("tabSize",4,function(a){Ja(a);oa(a);K(a,!0)},!0);v("electricChars",!0);v("theme","default",function(a){Tb(a);pa(a)},!0);v("keyMap","default",function(a){var b=O[a.options.keyMap].style;a.display.wrapper.className=
a.display.wrapper.className.replace(/\s*cm-keymap-\S+/g,"")+(b?" cm-keymap-"+b:"")});v("extraKeys",null);v("onKeyEvent",null);v("onDragEvent",null);v("lineWrapping",!1,function(a){var b=a.view.doc,c=X(a.display);if(a.options.lineWrapping){a.display.wrapper.className=a.display.wrapper.className+" CodeMirror-wrap";var d=a.display.scroller.clientWidth/hc(a.display)-3;b.iter(0,b.size,function(a){if(a.height!=0){var b=Math.ceil(a.text.length/d)||1;b!=1&&S(a,b*c)}});a.display.sizer.style.minWidth=""}else{a.display.wrapper.className=
a.display.wrapper.className.replace(" CodeMirror-wrap","");Vb(a.view);b.iter(0,b.size,function(a){a.height!=0&&S(a,c)})}U(a,0,b.size);oa(a);setTimeout(function(){Wb(a.display,a.view.doc.height)},100)},!0);v("gutters",[],function(a){pb(a.options);pa(a)},!0);v("lineNumbers",!1,function(a){pb(a.options);pa(a)},!0);v("firstLineNumber",1,pa,!0);v("lineNumberFormatter",function(a){return a},pa,!0);v("showCursorWhenSelecting",!1,vb,!0);v("readOnly",!1,function(a,b){if(b=="nocursor"){rb(a);a.display.input.blur()}else b||
ba(a,true)});v("dragDrop",!0);v("cursorBlinkRate",530);v("cursorHeight",1);v("workTime",100);v("workDelay",100);v("flattenSpans",!0);v("pollInterval",100);v("undoDepth",40);v("viewportMargin",10,function(a){a.refresh()},!0);v("tabindex",null,function(a,b){a.display.input.tabIndex=b||""});v("autofocus",null);var Rc=n.modes={},Qb=n.mimeModes={};n.defineMode=function(a,b){!n.defaults.mode&&"null"!=a&&(n.defaults.mode=a);if(2<arguments.length){b.dependencies=[];for(var c=2;c<arguments.length;++c)b.dependencies.push(arguments[c])}Rc[a]=
b};n.defineMIME=function(a,b){Qb[a]=b};n.resolveMode=function(a){if("string"==typeof a&&Qb.hasOwnProperty(a))a=Qb[a];else if("string"==typeof a&&/^[\w\-]+\/[\w\-]+\+xml$/.test(a))return n.resolveMode("application/xml");return"string"==typeof a?{name:a}:a||{name:"null"}};n.getMode=function(a,b){var b=n.resolveMode(b),c=Rc[b.name];if(!c)return n.getMode(a,"text/plain");c=c(a,b);if(Ga.hasOwnProperty(b.name)){var d=Ga[b.name],e;for(e in d)d.hasOwnProperty(e)&&(c.hasOwnProperty(e)&&(c["_"+e]=c[e]),c[e]=
d[e])}c.name=b.name;return c};n.defineMode("null",function(){return{token:function(a){a.skipToEnd()}}});n.defineMIME("text/plain","null");var Ga=n.modeExtensions={};n.extendMode=function(a,b){var c=Ga.hasOwnProperty(a)?Ga[a]:Ga[a]={},d;for(d in b)b.hasOwnProperty(d)&&(c[d]=b[d])};n.defineExtension=function(a,b){n.prototype[a]=b};n.defineOption=v;var sb=[];n.defineInitHook=function(a){sb.push(a)};n.copyState=ga;n.startState=ec;n.innerMode=function(a,b){for(;a.innerMode;)var c=a.innerMode(b),b=c.state,
a=c.mode;return c||{mode:a,state:b}};var Ib=n.commands={selectAll:function(a){a.setSelection({line:0,ch:0},{line:a.lineCount()-1})},killLine:function(a){var b=a.getCursor(!0),c=a.getCursor(!1),d=!x(b,c);!d&&a.getLine(b.line).length==b.ch?a.replaceRange("",b,{line:b.line+1,ch:0},"delete"):a.replaceRange("",b,d?c:{line:b.line},"delete")},deleteLine:function(a){var b=a.getCursor().line;a.replaceRange("",{line:b,ch:0},{line:b},"delete")},undo:function(a){a.undo()},redo:function(a){a.redo()},goDocStart:function(a){a.extendSelection({line:0,
ch:0})},goDocEnd:function(a){a.extendSelection({line:a.lineCount()-1})},goLineStart:function(a){a.extendSelection(Pc(a,a.getCursor().line))},goLineStartSmart:function(a){var b=a.getCursor(),c=Pc(a,b.line),d=a.getLineHandle(c.line),e=L(d);!e||0==e[0].level?(d=Math.max(0,d.text.search(/\S/)),a.extendSelection({line:c.line,ch:b.line==c.line&&b.ch<=d&&b.ch?0:d})):a.extendSelection(c)},goLineEnd:function(a){a.extendSelection(xd(a,a.getCursor().line))},goLineUp:function(a){a.moveV(-1,"line")},goLineDown:function(a){a.moveV(1,
"line")},goPageUp:function(a){a.moveV(-1,"page")},goPageDown:function(a){a.moveV(1,"page")},goCharLeft:function(a){a.moveH(-1,"char")},goCharRight:function(a){a.moveH(1,"char")},goColumnLeft:function(a){a.moveH(-1,"column")},goColumnRight:function(a){a.moveH(1,"column")},goWordLeft:function(a){a.moveH(-1,"word")},goWordRight:function(a){a.moveH(1,"word")},delCharBefore:function(a){a.deleteH(-1,"char")},delCharAfter:function(a){a.deleteH(1,"char")},delWordBefore:function(a){a.deleteH(-1,"word")},delWordAfter:function(a){a.deleteH(1,
"word")},indentAuto:function(a){a.indentSelection("smart")},indentMore:function(a){a.indentSelection("add")},indentLess:function(a){a.indentSelection("subtract")},insertTab:function(a){a.replaceSelection("\t","end","input")},defaultTab:function(a){a.somethingSelected()?a.indentSelection("add"):a.replaceSelection("\t","end","input")},transposeChars:function(a){var b=a.getCursor(),c=a.getLine(b.line);0<b.ch&&b.ch<c.length-1&&a.replaceRange(c.charAt(b.ch)+c.charAt(b.ch-1),{line:b.line,ch:b.ch-1},{line:b.line,
ch:b.ch+1})},newlineAndIndent:function(a){o(a,function(){a.replaceSelection("\n","end","input");a.indentLine(a.getCursor().line,null,!0)})()},toggleOverwrite:function(a){a.toggleOverwrite()}},O=n.keyMap={};O.basic={Left:"goCharLeft",Right:"goCharRight",Up:"goLineUp",Down:"goLineDown",End:"goLineEnd",Home:"goLineStartSmart",PageUp:"goPageUp",PageDown:"goPageDown",Delete:"delCharAfter",Backspace:"delCharBefore",Tab:"defaultTab","Shift-Tab":"indentAuto",Enter:"newlineAndIndent",Insert:"toggleOverwrite"};
O.pcDefault={"Ctrl-A":"selectAll","Ctrl-D":"deleteLine","Ctrl-Z":"undo","Shift-Ctrl-Z":"redo","Ctrl-Y":"redo","Ctrl-Home":"goDocStart","Alt-Up":"goDocStart","Ctrl-End":"goDocEnd","Ctrl-Down":"goDocEnd","Ctrl-Left":"goWordLeft","Ctrl-Right":"goWordRight","Alt-Left":"goLineStart","Alt-Right":"goLineEnd","Ctrl-Backspace":"delWordBefore","Ctrl-Delete":"delWordAfter","Ctrl-S":"save","Ctrl-F":"find","Ctrl-G":"findNext","Shift-Ctrl-G":"findPrev","Shift-Ctrl-F":"replace","Shift-Ctrl-R":"replaceAll","Ctrl-[":"indentLess",
"Ctrl-]":"indentMore",fallthrough:"basic"};O.macDefault={"Cmd-A":"selectAll","Cmd-D":"deleteLine","Cmd-Z":"undo","Shift-Cmd-Z":"redo","Cmd-Y":"redo","Cmd-Up":"goDocStart","Cmd-End":"goDocEnd","Cmd-Down":"goDocEnd","Alt-Left":"goWordLeft","Alt-Right":"goWordRight","Cmd-Left":"goLineStart","Cmd-Right":"goLineEnd","Alt-Backspace":"delWordBefore","Ctrl-Alt-Backspace":"delWordAfter","Alt-Delete":"delWordAfter","Cmd-S":"save","Cmd-F":"find","Cmd-G":"findNext","Shift-Cmd-G":"findPrev","Cmd-Alt-F":"replace",
"Shift-Cmd-Alt-F":"replaceAll","Cmd-[":"indentLess","Cmd-]":"indentMore",fallthrough:["basic","emacsy"]};O["default"]=fa?O.macDefault:O.pcDefault;O.emacsy={"Ctrl-F":"goCharRight","Ctrl-B":"goCharLeft","Ctrl-P":"goLineUp","Ctrl-N":"goLineDown","Alt-F":"goWordRight","Alt-B":"goWordLeft","Ctrl-A":"goLineStart","Ctrl-E":"goLineEnd","Ctrl-V":"goPageDown","Shift-Ctrl-V":"goPageUp","Ctrl-D":"delCharAfter","Ctrl-H":"delCharBefore","Alt-D":"delWordAfter","Alt-Backspace":"delWordBefore","Ctrl-K":"killLine",
"Ctrl-T":"transposeChars"};n.isModifierKey=wc;n.fromTextArea=function(a,b){function c(){a.value=k.getValue()}b||(b={});b.value=a.value;!b.tabindex&&a.tabindex&&(b.tabindex=a.tabindex);if(null==b.autofocus){var d=document.body;try{d=document.activeElement}catch(e){}b.autofocus=d==a||null!=a.getAttribute("autofocus")&&d==document.body}if(a.form){t(a.form,"submit",c);var f=a.form,g=f.submit;try{f.submit=function i(){c();f.submit=g;f.submit();f.submit=i}}catch(h){}}a.style.display="none";var k=n(function(b){a.parentNode.insertBefore(b,
a.nextSibling)},b);k.save=c;k.getTextArea=function(){return a};k.toTextArea=function(){c();a.parentNode.removeChild(k.getWrapperElement());a.style.display="";if(a.form){M(a.form,"submit",c);if(typeof a.form.submit=="function")a.form.submit=g}};return k};Fa.prototype={eol:function(){return this.pos>=this.string.length},sol:function(){return 0==this.pos},peek:function(){return this.string.charAt(this.pos)||void 0},next:function(){if(this.pos<this.string.length)return this.string.charAt(this.pos++)},
eat:function(a){var b=this.string.charAt(this.pos);if("string"==typeof a?b==a:b&&(a.test?a.test(b):a(b)))return++this.pos,b},eatWhile:function(a){for(var b=this.pos;this.eat(a););return this.pos>b},eatSpace:function(){for(var a=this.pos;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>a},skipToEnd:function(){this.pos=this.string.length},skipTo:function(a){a=this.string.indexOf(a,this.pos);if(-1<a)return this.pos=a,!0},backUp:function(a){this.pos-=a},column:function(){return ha(this.string,
this.start,this.tabSize)},indentation:function(){return ha(this.string,null,this.tabSize)},match:function(a,b,c){if("string"==typeof a){if((c?this.string.toLowerCase():this.string).indexOf(c?a.toLowerCase():a,this.pos)==this.pos)return!1!==b&&(this.pos+=a.length),!0}else{if((a=this.string.slice(this.pos).match(a))&&0<a.index)return null;a&&!1!==b&&(this.pos+=a[0].length);return a}},current:function(){return this.string.slice(this.start,this.pos)}};n.StringStream=Fa;Mb.prototype.clear=function(){if(!this.explicitlyCleared){Bb(this.cm);
for(var a=null,b=null,c=0;c<this.lines.length;++c){var d=this.lines[c],e=jb(d.markedSpans,this);null!=e.to&&(b=G(d));for(var f=d,g=d.markedSpans,h=e,k=void 0,j=0;j<g.length;++j)g[j]!=h&&(k||(k=[])).push(g[j]);f.markedSpans=k;null!=e.from?a=G(d):this.collapsed&&!R(d)&&S(d,X(this.cm.display))}null!=a&&U(this.cm,a,b+1);this.lines.length=0;this.explicitlyCleared=!0;this.collapsed&&this.cm.view.cantEdit&&(this.cm.view.cantEdit=!1,Ac(this.cm));Cb(this.cm);ea(this.cm,this,"clear")}};Mb.prototype.find=function(){for(var a,
b,c=0;c<this.lines.length;++c){var d=this.lines[c],e=jb(d.markedSpans,this);if(null!=e.from||null!=e.to)d=G(d),null!=e.from&&(a={line:d,ch:e.from}),null!=e.to&&(b={line:d,ch:e.to})}return"bookmark"==this.type?a:a&&{from:a,to:b}};window.lineIsHidden=R;var Jc={},Nb=/[\t\u0000-\u0019\u200b\u2028\u2029\uFEFF]/g;Ia.prototype={chunkSize:function(){return this.lines.length},remove:function(a,b,c){for(var d=a,e=a+b;d<e;++d){var f=this.lines[d];this.height-=f.height;var g=f;g.parent=null;Gc(g);ea(c,f,"delete")}this.lines.splice(a,
b)},collapse:function(a){a.splice.apply(a,[a.length,0].concat(this.lines))},insertHeight:function(a,b,c){this.height+=c;this.lines=this.lines.slice(0,a).concat(b).concat(this.lines.slice(a));a=0;for(c=b.length;a<c;++a)b[a].parent=this},iterN:function(a,b,c){for(b=a+b;a<b;++a)if(c(this.lines[a]))return!0}};Ha.prototype={chunkSize:function(){return this.size},remove:function(a,b,c){this.size-=b;for(var d=0;d<this.children.length;++d){var e=this.children[d],f=e.chunkSize();if(a<f){var g=Math.min(b,f-
a),h=e.height;e.remove(a,g,c);this.height-=h-e.height;f==g&&(this.children.splice(d--,1),e.parent=null);if(0==(b-=g))break;a=0}else a-=f}25>this.size-b&&(a=[],this.collapse(a),this.children=[new Ia(a)],this.children[0].parent=this)},collapse:function(a){for(var b=0,c=this.children.length;b<c;++b)this.children[b].collapse(a)},insert:function(a,b){for(var c=0,d=0,e=b.length;d<e;++d)c+=b[d].height;this.insertHeight(a,b,c)},insertHeight:function(a,b,c){this.size+=b.length;this.height+=c;for(var d=0,e=
this.children.length;d<e;++d){var f=this.children[d],g=f.chunkSize();if(a<=g){f.insertHeight(a,b,c);if(f.lines&&50<f.lines.length){for(;50<f.lines.length;)a=f.lines.splice(f.lines.length-25,25),a=new Ia(a),f.height-=a.height,this.children.splice(d+1,0,a),a.parent=this;this.maybeSpill()}break}a-=g}},maybeSpill:function(){if(!(10>=this.children.length)){var a=this;do{var b=a.children.splice(a.children.length-5,5),b=new Ha(b);if(a.parent){a.size-=b.size;a.height-=b.height;var c=kb(a.parent.children,
a);a.parent.children.splice(c+1,0,b)}else c=new Ha(a.children),c.parent=a,a.children=[c,b],a=c;b.parent=a.parent}while(10<a.children.length);a.parent.maybeSpill()}},iter:function(a,b,c){this.iterN(a,b-a,c)},iterN:function(a,b,c){for(var d=0,e=this.children.length;d<e;++d){var f=this.children[d],g=f.chunkSize();if(a<g){g=Math.min(b,g-a);if(f.iterN(a,g,c))return!0;if(0==(b-=g))break;a=0}else a-=g}}};n.e_stop=Xa;n.e_preventDefault=A;n.e_stopPropagation=Nc;n.on=t;n.off=M;n.signal=ia;var na=30,sc=n.Pass=
{toString:function(){return"CodeMirror.Pass"}};ub.prototype={set:function(a,b){clearTimeout(this.id);this.id=setTimeout(b,a)}};n.countColumn=ha;var mb=[""],wd=/[\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc]/,Ab=/[\u0300-\u036F\u0483-\u0487\u0488-\u0489\u0591-\u05BD\u05BF\u05C1-\u05C2\u05C4-\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7-\u06E8\u06EA-\u06ED\uA66F\uA670-\uA672\uA674-\uA67D\uA69F]/,nd=function(){if(cb)return!1;var a=r("div");return"draggable"in a||
"dragDrop"in a}(),lb=/^$/;V?lb=/$'/:Gb?lb=/\-[^ \-?]|\?[^ !'\"\),.\-\/:;\?\]\}]/:Qc&&(lb=/\-[^ \-\.?]|\?[^ \-\.?\]\}:;!'\"\),\/]|[\.!\"#&%\)*+,:;=>\]|\}~][\(\{\[<]|\$'/);var nb,Ob,xa=3!="\n\nb".split(/\n/).length?function(a){for(var b=0,c=[],d=a.length;b<=d;){var e=a.indexOf("\n",b);-1==e&&(e=a.length);var f=a.slice(b,"\r"==a.charAt(e-1)?e-1:e),g=f.indexOf("\r");-1!=g?(c.push(f.slice(0,g)),b+=g+1):(c.push(f),b=e+1)}return c}:function(a){return a.split(/\r\n?|\n/)};n.splitLines=xa;var hd=window.getSelection?
function(a){try{return a.selectionStart!=a.selectionEnd}catch(b){return!1}}:function(a){try{var b=a.ownerDocument.selection.createRange()}catch(c){}return!b||b.parentElement()!=a?!1:0!=b.compareEndPoints("StartToEnd",b)},jc=function(){var a=r("div");if("oncopy"in a)return!0;a.setAttribute("oncopy","return;");return"function"==typeof a.oncopy}(),aa={3:"Enter",8:"Backspace",9:"Tab",13:"Enter",16:"Shift",17:"Ctrl",18:"Alt",19:"Pause",20:"CapsLock",27:"Esc",32:"Space",33:"PageUp",34:"PageDown",35:"End",
36:"Home",37:"Left",38:"Up",39:"Right",40:"Down",44:"PrintScrn",45:"Insert",46:"Delete",59:";",91:"Mod",92:"Mod",93:"Mod",109:"-",107:"=",127:"Delete",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'",63276:"PageUp",63277:"PageDown",63275:"End",63273:"Home",63234:"Left",63232:"Up",63235:"Right",63233:"Down",63302:"Insert",63272:"Delete"};n.keyNames=aa;(function(){for(var a=0;10>a;a++)aa[a+48]=""+a;for(a=65;90>=a;a++)aa[a]=String.fromCharCode(a);for(a=1;12>=a;a++)aa[a+
111]=aa[a+63235]="F"+a})();var ud=function(){function a(a){return 255>=a?b.charAt(a):1424<=a&&1524>=a?"R":1536<=a&&1791>=a?c.charAt(a-1536):1792<=a&&2220>=a?"r":"L"}var b="bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLL",c="rrrrrrrrrrrr,rNNmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmrrrrrrrnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmNmmmmrrrrrrrrrrrrrrrrrr",
d=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/,e=/[stwN]/,f=/[LRr]/,g=/[Lb1n]/,h=/[1n]/;return function(b){if(!d.test(b))return!1;for(var c=b.length,i=[],m=null,l=0,p;l<c;++l)if(i.push(p=a(b.charCodeAt(l))),null==m)if("L"==p)m="L";else if("R"==p||"r"==p)m="R";null==m&&(m="L");for(var l=0,n=m;l<c;++l)p=i[l],"m"==p?i[l]=n:n=p;l=0;for(n=m;l<c;++l)p=i[l],"1"==p&&"r"==n?i[l]="n":f.test(p)&&(n=p,"r"==p&&(i[l]="R"));l=1;for(n=i[0];l<c-1;++l){p=i[l];if("+"==p&&"1"==n&&"1"==i[l+1])i[l]="1";else if(","==p&&
n==i[l+1]&&("1"==n||"n"==n))i[l]=n;n=p}for(l=0;l<c;++l)if(p=i[l],","==p)i[l]="N";else if("%"==p){for(n=l+1;n<c&&"%"==i[n];++n);var o=l&&"!"==i[l-1]||n<c-1&&"1"==i[n]?"1":"N";for(p=l;p<n;++p)i[p]=o;l=n-1}l=0;for(n=m;l<c;++l)p=i[l],"L"==n&&"1"==p?i[l]="L":f.test(p)&&(n=p);for(l=0;l<c;++l)if(e.test(i[l])){for(n=l+1;n<c&&e.test(i[n]);++n);p="L"==(n<c-1?i[n]:m);o="L"==(l?i[l-1]:m)||p?"L":"R";for(p=l;p<n;++p)i[p]=o;l=n-1}for(var m=[],q,l=0;l<c;)if(g.test(i[l])){p=l;for(++l;l<c&&g.test(i[l]);++l);m.push({from:p,
to:l,level:0})}else{o=l;n=m.length;for(++l;l<c&&"L"!=i[l];++l);for(p=o;p<l;)if(h.test(i[p])){o<p&&m.splice(n,0,{from:o,to:p,level:1});o=p;for(++p;p<l&&h.test(i[p]);++p);m.splice(n,0,{from:o,to:p,level:2});o=p}else++p;o<l&&m.splice(n,0,{from:o,to:l,level:1})}if(1==m[0].level&&(q=b.match(/^\s+/)))m[0].from=q[0].length,m.unshift({from:0,to:q[0].length,level:0});if(1==I(m).level&&(q=b.match(/\s+$/)))I(m).to-=q[0].length,m.push({from:c-q[0].length,to:c,level:0});m[0].level!=I(m).level&&m.push({from:c,
to:c,level:m[0].level});return m}}();n.version="3.0";return n}();